ext/tal.py
changeset 8695 358d8bed9626
parent 8537 e30d0a7f0087
child 10590 7629902e7554
equal deleted inserted replaced
8694:d901c36bcfce 8695:358d8bed9626
   180 
   180 
   181     def expandInline(self, context, outputFile, interpreter):
   181     def expandInline(self, context, outputFile, interpreter):
   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, 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             raise simpleTALES.ContextContentException("found non-unicode %r string in Context!" % unierror.args[1]), None, sys.exc_info()[-1]
   188 
   188 
   189 
   189 
   190 def compile_template(template):
   190 def compile_template(template):
   228             value = value.rawValue()
   228             value = value.rawValue()
   229         locals[name] = value
   229         locals[name] = value
   230     # XXX precompile expr will avoid late syntax error
   230     # XXX precompile expr will avoid late syntax error
   231     try:
   231     try:
   232         result = eval(expr, globals, locals)
   232         result = eval(expr, globals, locals)
   233     except Exception, ex:
   233     except Exception as ex:
   234         ex = ex.__class__('in %r: %s' % (expr, ex))
   234         ex = ex.__class__('in %r: %s' % (expr, ex))
   235         raise ex, None, sys.exc_info()[-1]
   235         raise ex, None, sys.exc_info()[-1]
   236     if (isinstance (result, simpleTALES.ContextVariable)):
   236     if (isinstance (result, simpleTALES.ContextVariable)):
   237         return result.value()
   237         return result.value()
   238     return result
   238     return result