This commit is contained in:
ymq1 2025-06-11 07:57:13 +00:00
parent 5f7580d795
commit b8aeba79e8
5 changed files with 18 additions and 11 deletions

View File

@ -149,7 +149,7 @@ class TemplateProcessor(BaseProcessor):
async def path_call(self, request, params={}):
await self.set_run_env(request, params=params)
path = request.path
path = params.get('path', request.path)
ns = self.run_ns
te = self.run_ns['tmpl_engine']
return await te.render(path,**ns)
@ -197,7 +197,8 @@ class BricksUIProcessor(TemplateProcessor):
entire_url = self.run_ns.get('entire_url')
content0 = await self.resource.path_call(request,entire_url('/bricks/header.tmpl'))
content2 = await self.resource.path_call(request,entire_url('/bricks/footer.tmpl'))
self.content = '%s%s%s' % (content0, txt, content2)
self.content = f'{content0}{txt}{content2}'
debug(f'{len(txt)=}, {len(content0)=}, {len(content2)=}, {self.content=}')
class PythonScriptProcessor(BaseProcessor):
@classmethod
@ -218,7 +219,8 @@ class PythonScriptProcessor(BaseProcessor):
await self.set_run_env(request, params=params)
lenv = self.run_ns
del lenv['request']
txt = await self.loadScript(self.real_path)
fpath = params.get('fpath', self.real_path)
txt = await self.loadScript(fpath)
# print(self.real_path, "#########", txt)
exec(txt,lenv,lenv)
func = lenv['myfunc']

View File

@ -50,7 +50,7 @@ class DataSourceProcessor(BaseProcessor):
}
return ret
async def path_call(self, request, path):
async def path_call(self, request, path, params={}):
dict_data = {}
config = getConfig()
async with aiofiles.open(path,'r',encoding=config.website.coding) as f:

View File

@ -16,10 +16,11 @@ class FunctionProcessor(BaseProcessor):
self.config_opts = opts
BaseProcessor.__init__(self,path,resource)
async def path_call(self, request, path):
async def path_call(self, request, params={}):
await self.set_run_env(request)
parmas_kw = self.run_ns.get('params_kw')
path1 = request.path[len(self.config_opts['leading']):]
path = params.get('path', request.path)
path1 = path[len(self.config_opts['leading']):]
args = []
if len(path1) > 0:
if path1[0] == '/':
@ -34,8 +35,8 @@ class FunctionProcessor(BaseProcessor):
if f is None:
error(f'{rfname=} is not registered, {rf.registKW=}')
return None
self.run_ns['request'] = request
globals().update(self.run_ns)
# self.run_ns['request'] = request
# globals().update(self.run_ns)
debug(f'params_kw={params_kw}, {args=}')
if inspect.iscoroutinefunction(f):

View File

@ -463,10 +463,12 @@ class ProcessorResource(StaticResource,Url2File):
async def path_call(self, request, path, params={}):
url = self.entireUrl(request, path)
# print(f'{path=}, after entireUrl(), {url=}')
debug(f'{path=}, after entireUrl(), {url=}')
path = self.url2path(url)
fpath = self.url2file(path)
processor = self.url2processor(request, path, fpath)
# print(f'path_call(), {path=}, {url=}, {fpath=}, {processor=}, {self._prepath}')
debug(f'path_call(), {path=}, {url=}, {fpath=}, {processor=}, {self._prepath}')
params['path'] = path
params['fpath'] = fpath
return await processor.be_call(request, params=params)

View File

@ -1,5 +1,6 @@
import aiohttp
from appPublic.log import info, debug, warning, error, critical, exception
# from appPublic.streamhttpclient import StreamHttpClient
from aiohttp import web, BasicAuth
from aiohttp import client
from .baseProcessor import *
@ -11,7 +12,7 @@ class ProxyProcessor(BaseProcessor):
async def path_call(self, request, params={}):
await self.set_run_env(request)
path = self.path
path = params.get('path', request.path)
url = self.resource.entireUrl(request, path)
ns = self.run_ns
ns.update(params)
@ -33,6 +34,7 @@ class ProxyProcessor(BaseProcessor):
params = None
if d.get('params'):
params = params
async with client.request(
d.get('method', request.method),
d['url'],