bugfix
This commit is contained in:
commit
46b167d7d4
@ -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']
|
||||
|
@ -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:
|
||||
|
@ -38,10 +38,10 @@ async def file_handle(request, filepath, download=False):
|
||||
async def file_download(request, filepath):
|
||||
return await file_handle(request, filepath, download=True)
|
||||
|
||||
async def path_download(request, kw, *params):
|
||||
path = kw.get('path')
|
||||
async def path_download(request, params_kw, *params, **kw):
|
||||
path = params_kw.get('path')
|
||||
download = False
|
||||
if kw.get('download'):
|
||||
if params_kw.get('download'):
|
||||
download = True
|
||||
fs = FileStorage()
|
||||
fp = fs.realPath(path)
|
||||
|
@ -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):
|
||||
|
@ -463,11 +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}')
|
||||
new_request = request.clone(rel_url=path)
|
||||
return await processor.be_call(new_request, params=params)
|
||||
debug(f'path_call(), {path=}, {url=}, {fpath=}, {processor=}, {self._prepath}')
|
||||
params['path'] = path
|
||||
params['fpath'] = fpath
|
||||
return await processor.be_call(request, params=params)
|
||||
|
||||
|
@ -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'],
|
||||
|
@ -14,9 +14,9 @@ def webapp(init_func):
|
||||
args = parser.parse_args()
|
||||
workdir = args.workdir or os.getcwd()
|
||||
port = args.port
|
||||
server(init_func, workdir, port)
|
||||
webserver(init_func, workdir, port)
|
||||
|
||||
def server(init_func, workdir, port=None):
|
||||
def webserver(init_func, workdir, port=None):
|
||||
p = ProgramPath()
|
||||
config = getConfig(workdir, NS={'workdir':workdir, 'ProgramPath':p})
|
||||
if config.logger:
|
||||
|
Loading…
Reference in New Issue
Block a user