This commit is contained in:
yumoqing 2022-09-13 13:29:06 +08:00
parent 82d75642b4
commit 35c5cd3452
2 changed files with 20 additions and 8 deletions

View File

@ -1,3 +1,4 @@
import traceback
try:
import ujson as json
except:
@ -90,7 +91,12 @@ class TemplateHandler(BaseHandler):
self.engine = MyTemplateEngine(paths)
def render(self):
try:
return self.engine.render(self.templ_file, self.env)
except Exception as e:
print('Exception:', str(e))
print('filename=', self.env['filepath'])
traceback.print_exc()
class DspyHandler(BaseHandler):
def __init__(self, env):
@ -107,9 +113,15 @@ class DspyHandler(BaseHandler):
return txt
def render(self, params={}):
try:
lenv = self.env.copy()
lenv.update(params)
txt = self.loadScript(self.env['filepath'])
exec(txt,lenv,lenv)
func = lenv['myfunc']
return func(self.env, **lenv)
except Exception as e:
print('Exception:', str(e))
print('filename=', self.env['filepath'])
traceback.print_exc()

View File

@ -1 +1 @@
__version__ = '0.3.7'
__version__ = '0.3.8'