bugfix
This commit is contained in:
parent
1834fde7d5
commit
ef186b8d44
@ -5,8 +5,6 @@ import codecs
|
|||||||
from aiohttp.web_request import Request
|
from aiohttp.web_request import Request
|
||||||
from aiohttp.web_response import Response, StreamResponse
|
from aiohttp.web_response import Response, StreamResponse
|
||||||
|
|
||||||
from jinja2 import Template,Environment,BaseLoader
|
|
||||||
|
|
||||||
from appPublic.jsonConfig import getConfig
|
from appPublic.jsonConfig import getConfig
|
||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
from appPublic.folderUtils import listFile
|
from appPublic.folderUtils import listFile
|
||||||
@ -64,7 +62,9 @@ class BaseProcessor:
|
|||||||
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['params_kw'] = await self.run_ns['request2ns']()
|
kw = await self.run_ns['request2ns']()
|
||||||
|
self.run_ns['params_kw'] = kw
|
||||||
|
self.run_ns.update(kw)
|
||||||
self.run_ns['ref_real_path'] = self.path
|
self.run_ns['ref_real_path'] = self.path
|
||||||
|
|
||||||
async def execute(self,request):
|
async def execute(self,request):
|
||||||
@ -108,7 +108,7 @@ class TemplateProcessor(BaseProcessor):
|
|||||||
ns = self.run_ns
|
ns = self.run_ns
|
||||||
ns.update(params)
|
ns.update(params)
|
||||||
te = self.run_ns['tmpl_engine']
|
te = self.run_ns['tmpl_engine']
|
||||||
return te.render(url,**ns)
|
return await te.render(url,**ns)
|
||||||
|
|
||||||
async def datahandle(self,request):
|
async def datahandle(self,request):
|
||||||
self.content = await self.path_call(request)
|
self.content = await self.path_call(request)
|
||||||
|
@ -34,16 +34,16 @@ class TmplLoader(BaseLoader, TmplUrl2File):
|
|||||||
|
|
||||||
class TemplateEngine(Environment):
|
class TemplateEngine(Environment):
|
||||||
def __init__(self,loader=None):
|
def __init__(self,loader=None):
|
||||||
Environment.__init__(self,loader=loader)
|
Environment.__init__(self,loader=loader, enable_async=True)
|
||||||
self.urlpaths = {}
|
self.urlpaths = {}
|
||||||
self.loader = loader
|
self.loader = loader
|
||||||
|
|
||||||
def join_path(self,template: str, parent: str):
|
def join_path(self,template: str, parent: str):
|
||||||
return self.loader.join_path(template, parent)
|
return self.loader.join_path(template, parent)
|
||||||
|
|
||||||
def render(self,___name: str, **globals):
|
async 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 await t.render_async(globals)
|
||||||
|
|
||||||
def setupTemplateEngine():
|
def setupTemplateEngine():
|
||||||
config = getConfig()
|
config = getConfig()
|
||||||
|
Loading…
Reference in New Issue
Block a user