This commit is contained in:
yumoqing 2019-11-29 18:01:58 +08:00
parent a7adbf9f8f
commit 7110fad601
2 changed files with 6 additions and 7 deletions

View File

@ -58,11 +58,11 @@ class BaseProcessor:
async def handle(self,request): async def handle(self,request):
g = ServerEnv() g = ServerEnv()
self.run_ns = DictObject() self.run_ns = {}
self.run_ns.update(g) self.run_ns.update(g)
self.run_ns.update(self.resource.y_env) self.run_ns.update(self.resource.y_env)
self.run_ns.request = request self.run_ns['request'] = request
self.run_ns.ref_real_path = self.path self.run_ns['ref_real_path'] = self.path
ns = await self.resource.y_env.request2ns() ns = await self.resource.y_env.request2ns()
self.run_ns.update(ns) self.run_ns.update(ns)
await self.datahandle(request) await self.datahandle(request)
@ -92,8 +92,7 @@ class TemplateProcessor(BaseProcessor):
async def datahandle(self,request): async def datahandle(self,request):
path = request.path path = request.path
ns = self.run_ns ns = self.run_ns
te = self.run_ns.tmpl_engine te = self.run_ns['tmpl_engine']
print('ns=',ns)
self.content = te.render(path,**ns) self.content = te.render(path,**ns)
def setheaders(self): def setheaders(self):

View File

@ -41,8 +41,8 @@ class TemplateEngine(Environment):
return self.loader.join_path(template, parent) return self.loader.join_path(template, parent)
def render(self,name: str, **globals): def render(self,___name: str, **globals):
t = self.get_template(name,globals=globals) t = self.get_template(___name,globals=globals)
return t.render(globals) return t.render(globals)
def setupTemplateEngine(): def setupTemplateEngine():