Genshi wants the context as keyword arguments.
[toast/alpenzoo.git] / django_template_backend_genshi / __init__.py
index c09af8c3ab28cda01d3d53b91a2992d721b9966c..17240a21685dad65da3fa1a867b4acb169b22399 100644 (file)
@@ -1,9 +1,13 @@
 from django.template.backends.utils import csrf_input_lazy, csrf_token_lazy
 import django.template.backends.base
 import genshi.template
+import genshi.template.loader
+import genshi.template.base
 
 
 class GenshiEngine(django.template.backends.base.BaseEngine):
+    app_dirname = 'genshi'
+
     def __init__(self, params):
         params = params.copy()
         options = params.pop('OPTIONS').copy()
@@ -16,17 +20,17 @@ class GenshiEngine(django.template.backends.base.BaseEngine):
         try:
             template = genshi.template.MarkupTemplate(template_code)
             return GenshiTemplateWrapper(template)
-        except genshi.TemplateCompilationFailed as exc:
+        except genshi.template.base.TemplateSyntaxError as exc:
             raise django.template.TemplateSyntaxError(exc.args)
 
 
     def get_template(self, template_name):
         try:
             template = self.loader.load(template_name)
-            return GenshiTemplateWrapper(self.loader.get_template(template_name))
-        except genshi.TemplateNotFound as exc:
+            return GenshiTemplateWrapper(self.loader.load(template_name))
+        except genshi.template.loader.TemplateNotFound as exc:
             raise django.template.TemplateDoesNotExist(exc.args)
-        except genshi.TemplateCompilationFailed as exc:
+        except genshi.template.base.TemplateSyntaxError as exc:
             raise django.template.TemplateSyntaxError(exc.args)
 
 
@@ -41,5 +45,5 @@ class GenshiTemplateWrapper(object):
             context['request'] = request
             context['csrf_input'] = csrf_input_lazy(request)
             context['csrf_token'] = csrf_token_lazy(request)
-        stream = self.template.generate(dict=context)
+        stream = self.template.generate(**context)
         return stream.render()