ext/tal.py
changeset 10590 7629902e7554
parent 8695 358d8bed9626
child 10614 57dfde80df11
equal deleted inserted replaced
10589:7c23b7de2b8d 10590:7629902e7554
   182         """ Internally used when expanding a template that is part of a context."""
   182         """ Internally used when expanding a template that is part of a context."""
   183         try:
   183         try:
   184             interpreter.execute(self)
   184             interpreter.execute(self)
   185         except UnicodeError as unierror:
   185         except UnicodeError as unierror:
   186             LOGGER.exception(str(unierror))
   186             LOGGER.exception(str(unierror))
   187             raise simpleTALES.ContextContentException("found non-unicode %r string in Context!" % unierror.args[1]), None, sys.exc_info()[-1]
   187             exc = simpleTALES.ContextContentException(
       
   188                 "found non-unicode %r string in Context!" % unierror.args[1])
       
   189             exc.__traceback__ = sys.exc_info()[-1]
       
   190             raise exc
   188 
   191 
   189 
   192 
   190 def compile_template(template):
   193 def compile_template(template):
   191     """compiles a TAL template string
   194     """compiles a TAL template string
   192     :type template: unicode
   195     :type template: unicode
   230     # XXX precompile expr will avoid late syntax error
   233     # XXX precompile expr will avoid late syntax error
   231     try:
   234     try:
   232         result = eval(expr, globals, locals)
   235         result = eval(expr, globals, locals)
   233     except Exception as ex:
   236     except Exception as ex:
   234         ex = ex.__class__('in %r: %s' % (expr, ex))
   237         ex = ex.__class__('in %r: %s' % (expr, ex))
   235         raise ex, None, sys.exc_info()[-1]
   238         ex.__traceback__ = sys.exc_info()[-1]
       
   239         raise ex
   236     if (isinstance (result, simpleTALES.ContextVariable)):
   240     if (isinstance (result, simpleTALES.ContextVariable)):
   237         return result.value()
   241         return result.value()
   238     return result
   242     return result
   239 
   243 
   240 simpleTALES.Context.evaluatePython = evaluatePython
   244 simpleTALES.Context.evaluatePython = evaluatePython