Permalink
Browse files

first cut

  • Loading branch information...
mcdonc committed Aug 18, 2011
1 parent d9ea462 commit 83cfff1c320b6286cbae6f5cbb0981759f5913d9
Showing with 21 additions and 1 deletion.
  1. +21 −1 pyramid/mako_templating.py
View
@@ -1,4 +1,5 @@
import os
+import sys
import threading
from zope.interface import implements
@@ -110,6 +111,14 @@ def renderer_factory(info):
return MakoLookupTemplateRenderer(path, lookup)
+class MakoRenderingException(Exception):
+ def __init__(self, text):
+ self.text = text
+
+ def __repr__(self):
+ return self.text
+
+ __str__ = __repr__
class MakoLookupTemplateRenderer(object):
implements(ITemplateRenderer)
@@ -134,5 +143,16 @@ def __call__(self, value, system):
template = self.implementation()
if def_name is not None:
template = template.get_def(def_name)
- result = template.render_unicode(**system)
+ try:
+ result = template.render_unicode(**system)
+ except:
+ try:
+ exc_info = sys.exc_info()
+ errtext = exceptions.text_error_template().render(
+ error=exc_info[0],
+ traceback=exc_info[2])
+ raise MakoRenderingException(errtext)
+ finally:
+ del exc_info
+
return result

0 comments on commit 83cfff1

Please sign in to comment.