Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first cut

  • Loading branch information...
commit 83cfff1c320b6286cbae6f5cbb0981759f5913d9 1 parent d9ea462
@mcdonc mcdonc authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 pyramid/mako_templating.py
View
22 pyramid/mako_templating.py
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.