# HG changeset patch # User Jeff Hammel # Date 1288195777 25200 # Node ID afd11b758da031cc7fa1664a37684079bd45847d # Parent 7800c6553c77890820150741ec88f670ee2bf25c just require genshi for now diff -r 7800c6553c77 -r afd11b758da0 contenttransformer/transformers.py --- 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 diff -r 7800c6553c77 -r afd11b758da0 setup.py --- 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: -*-