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: try:
import ujson as json import ujson as json
except: except:
@ -90,7 +91,12 @@ class TemplateHandler(BaseHandler):
self.engine = MyTemplateEngine(paths) self.engine = MyTemplateEngine(paths)
def render(self): def render(self):
return self.engine.render(self.templ_file, self.env) 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): class DspyHandler(BaseHandler):
def __init__(self, env): def __init__(self, env):
@ -107,9 +113,15 @@ class DspyHandler(BaseHandler):
return txt return txt
def render(self, params={}): def render(self, params={}):
lenv = self.env.copy() try:
lenv.update(params) lenv = self.env.copy()
txt = self.loadScript(self.env['filepath']) lenv.update(params)
exec(txt,lenv,lenv) txt = self.loadScript(self.env['filepath'])
func = lenv['myfunc'] exec(txt,lenv,lenv)
return func(self.env, **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'