changeset 19:afd11b758da0

just require genshi for now
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 27 Oct 2010 09:09:37 -0700
parents 7800c6553c77
children 32a05d7bb214
files contenttransformer/transformers.py setup.py
diffstat 2 files changed, 25 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/contenttransformer/transformers.py	Sun Sep 26 19:58:46 2010 -0700
+++ b/contenttransformer/transformers.py	Wed Oct 27 09:09:37 2010 -0700
@@ -3,6 +3,9 @@
 from utils import import_path
 from webob import Request, Response
 
+import genshi
+from genshi.template import MarkupTemplate
+
 class Transformer(object):
     """abstract base class for transformer objects"""
     def __init__(self, content, content_type):
@@ -60,28 +63,23 @@
                                             settings_overrides=self.settings)
         return ('text/html', html)
 
-try:
-    import genshi
-    from genshi.template import MarkupTemplate
 
-    class GenshiTransformer(Transformer):
+class GenshiTransformer(Transformer):
 
-        def __init__(self, content, content_type, modules=()):
-            """
-            - modules : strings of modules
-            """
-            self.variables = {}
-            for path in modules:
-                module = import_path(path)
-                name = path.rsplit('.')[-1]
-                self.variables[name] = module
-            Transformer.__init__(self, content, content_type)
+    def __init__(self, content, content_type, modules=()):
+        """
+        - modules : strings of modules
+        """
+        self.variables = {}
+        for path in modules:
+            module = import_path(path)
+            name = path.rsplit('.')[-1]
+            self.variables[name] = module
+        Transformer.__init__(self, content, content_type)
         
-        def transform(self, request):
-            variables = dict(request=request)
-            template = MarkupTemplate(self.content)
-            stream = template.generate(**variables)
-            return ('text/html', stream.render('html', doctype='html'))
+    def transform(self, request):
+        variables = dict(request=request)
+        template = MarkupTemplate(self.content)
+        stream = template.generate(**variables)
+        return ('text/html', stream.render('html', doctype='html'))
 
-except ImportError:
-    pass
--- a/setup.py	Sun Sep 26 19:58:46 2010 -0700
+++ b/setup.py	Wed Oct 27 09:09:37 2010 -0700
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = "0.3.1"
+version = "0.3.2"
 
 setup(name='contenttransformer',
       version=version,
@@ -18,10 +18,11 @@
       zip_safe=False,
       install_requires=[
           # -*- Extra requirements: -*-
-         'WebOb',	
-         'Paste',
-         'PasteScript',
-         'docutils'
+        'WebOb',	
+        'Paste',
+        'PasteScript',
+        'docutils',
+        'genshi',
       ],
       entry_points="""
       # -*- Entry points: -*-