Skip to content

Commit

Permalink
first cut
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed Aug 18, 2011
1 parent d9ea462 commit 83cfff1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pyramid/mako_templating.py
@@ -1,4 +1,5 @@
import os
import sys
import threading

from zope.interface import implements
Expand Down Expand Up @@ -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)
Expand All @@ -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.