Compare commits
No commits in common. "44e51d6e93972b4781a0f28f0416fda1b45e382a" and "5f7580d7959c32d7fb5175d25fc0fa9ac10829a2" have entirely different histories.
44e51d6e93
...
5f7580d795
@ -149,7 +149,7 @@ class TemplateProcessor(BaseProcessor):
|
||||
|
||||
async def path_call(self, request, params={}):
|
||||
await self.set_run_env(request, params=params)
|
||||
path = params.get('path', request.path)
|
||||
path = request.path
|
||||
ns = self.run_ns
|
||||
te = self.run_ns['tmpl_engine']
|
||||
return await te.render(path,**ns)
|
||||
@ -197,8 +197,7 @@ 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 = f'{content0}{txt}{content2}'
|
||||
debug(f'{len(txt)=}, {len(content0)=}, {len(content2)=}, {self.content=}')
|
||||
self.content = '%s%s%s' % (content0, txt, content2)
|
||||
|
||||
class PythonScriptProcessor(BaseProcessor):
|
||||
@classmethod
|
||||
@ -219,8 +218,7 @@ class PythonScriptProcessor(BaseProcessor):
|
||||
await self.set_run_env(request, params=params)
|
||||
lenv = self.run_ns
|
||||
del lenv['request']
|
||||
fpath = params.get('fpath', self.real_path)
|
||||
txt = await self.loadScript(fpath)
|
||||
txt = await self.loadScript(self.real_path)
|
||||
# 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, params={}):
|
||||
async def path_call(self, request, path):
|
||||
dict_data = {}
|
||||
config = getConfig()
|
||||
async with aiofiles.open(path,'r',encoding=config.website.coding) as f:
|
||||
|
@ -16,11 +16,10 @@ class FunctionProcessor(BaseProcessor):
|
||||
self.config_opts = opts
|
||||
BaseProcessor.__init__(self,path,resource)
|
||||
|
||||
async def path_call(self, request, params={}):
|
||||
async def path_call(self, request, path):
|
||||
await self.set_run_env(request)
|
||||
parmas_kw = self.run_ns.get('params_kw')
|
||||
path = params.get('path', request.path)
|
||||
path1 = path[len(self.config_opts['leading']):]
|
||||
path1 = request.path[len(self.config_opts['leading']):]
|
||||
args = []
|
||||
if len(path1) > 0:
|
||||
if path1[0] == '/':
|
||||
@ -35,8 +34,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,12 +463,10 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
|
||||
async def path_call(self, request, path, params={}):
|
||||
url = self.entireUrl(request, path)
|
||||
debug(f'{path=}, after entireUrl(), {url=}')
|
||||
# print(f'{path=}, after entireUrl(), {url=}')
|
||||
path = self.url2path(url)
|
||||
fpath = self.url2file(path)
|
||||
processor = self.url2processor(request, path, fpath)
|
||||
debug(f'path_call(), {path=}, {url=}, {fpath=}, {processor=}, {self._prepath}')
|
||||
params['path'] = path
|
||||
params['fpath'] = fpath
|
||||
# print(f'path_call(), {path=}, {url=}, {fpath=}, {processor=}, {self._prepath}')
|
||||
return await processor.be_call(request, params=params)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
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 *
|
||||
@ -12,7 +11,7 @@ class ProxyProcessor(BaseProcessor):
|
||||
|
||||
async def path_call(self, request, params={}):
|
||||
await self.set_run_env(request)
|
||||
path = params.get('path', request.path)
|
||||
path = self.path
|
||||
url = self.resource.entireUrl(request, path)
|
||||
ns = self.run_ns
|
||||
ns.update(params)
|
||||
@ -34,7 +33,6 @@ class ProxyProcessor(BaseProcessor):
|
||||
params = None
|
||||
if d.get('params'):
|
||||
params = params
|
||||
|
||||
async with client.request(
|
||||
d.get('method', request.method),
|
||||
d['url'],
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name="ahserver"
|
||||
version = "1.0.3"
|
||||
version = "1.0.2"
|
||||
description = "A application server base on aiohttp"
|
||||
authors = [{ name = "yu moqing", email = "yumoqing@gmail.com" }]
|
||||
readme = "README.md"
|
||||
|
Loading…
Reference in New Issue
Block a user