From adc467d04a36660010e243661511314d92a9be5d Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 4 Jul 2023 12:02:13 +0800 Subject: [PATCH] bugfix --- ahserver/auth_api.py | 7 +++---- ahserver/baseProcessor.py | 3 +++ ahserver/processorResource.py | 12 +++++++----- change.log | 0 4 files changed, 13 insertions(+), 9 deletions(-) mode change 100644 => 100755 change.log diff --git a/ahserver/auth_api.py b/ahserver/auth_api.py index a305412..926c78d 100755 --- a/ahserver/auth_api.py +++ b/ahserver/auth_api.py @@ -15,6 +15,9 @@ class AuthAPI(AppLogger): super().__init__() self.conf = getConfig() + async def checkUserPermission(self, user, path): + return True + def getPrivateKey(self): if not hasattr(self,'rsaEngine'): self.rsaEngine = RSA() @@ -64,10 +67,6 @@ class AuthAPI(AppLogger): print(f'**{user=}, {path} forbidden**') raise web.HTTPForbidden() - async def checkUserPermission(self, user, path): - raise Exception('checkUserPermission()') - return False - async def needAuth(self,path): return False diff --git a/ahserver/baseProcessor.py b/ahserver/baseProcessor.py index 0098f9c..73b78a8 100755 --- a/ahserver/baseProcessor.py +++ b/ahserver/baseProcessor.py @@ -58,6 +58,9 @@ class BaseProcessor(AppLogger): } self.content = '' + async def be_call(self, request, params={}): + return await self.path_call(request, params=params) + async def set_run_env(self, request): if self.env_set: return diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index dd738b9..af87062 100755 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -116,7 +116,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): if request.query: return multiDict2Dict(request.query) ns = multiDict2Dict(md) - print(f'{ns=} reader is None, {request.query=}') + # print(f'{ns=} reader is None, {request.query=}') return ns ns = {} while 1: @@ -147,7 +147,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): print('-----------except out ------------') break; # showcallstack() - print(f'getPostData():{ns=}') + # print(f'getPostData():{ns=}') return ns async def _handle(self,request:Request) -> StreamResponse: @@ -329,8 +329,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): def url2processor(self, request, url, fpath): config = getConfig() url = self.entireUrl(request, url) - host = '/'.join(str(request.url).split('/')[:3]) - path = request.path + host = '/'.join(url.split('/')[:3]) + path = '/' + '/'.join(url.split('/')[3:]) real_path = self.abspath(request, path) if config.website.startswiths: for a in config.website.startswiths: @@ -365,5 +365,7 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): url = self.entireUrl(request, path) fpath = self.url2file(url) processor = self.url2processor(request, url, fpath) - return await processor.path_call(request, params=params) + new_request = request.clone(rel_url=url) + # new_request.path = path + return await processor.be_call(new_request, params=params) diff --git a/change.log b/change.log old mode 100644 new mode 100755