From a857a2b4a1203eb9a148ab5c2cd915ec386a2bdf Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 7 Apr 2023 13:16:54 +0800 Subject: [PATCH] bugfix --- ahserver/processorResource.py | 11 ++++++++--- ahserver/url2file.py | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index aa4b4eb..5c01c97 100644 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -100,7 +100,9 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): def abspath(self, request, path:str): url = self.entireUrl(request, path) - return self.url2file(url) + fname = self.url2file(url) + print(f'abspath():, {path=}, {url=}, {fname=}') + return fname async def getPostData(self,request: Request) -> dict: reader = await request.multipart() @@ -219,7 +221,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): self.y_env.path_call = partial(self.path_call,request) self.user = await auth.get_auth(request) self.y_env.user = self.user - self.request_filename = self.url2file(str(request.url)) + self.request_filename = self.url2file(str(request.path)) + print(f'225:{request.path=}, {self.request_filename=}') path = request.path config = getConfig() if config.website.dbadm and path.startswith(config.website.dbadm): @@ -310,6 +313,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): host = '/'.join(str(request.url).split('/')[:3]) path = url[len(host):].split('?')[0] real_path = self.abspath(request, path) + if real_path is None: + return None if config.website.startswiths: for a in config.website.startswiths: if path.startswith(a.leading): @@ -337,8 +342,8 @@ class ProcessorResource(AppLogger, StaticResource,Url2File): async def path_call(self, request, path, params={}): url = self.entireUrl(request, path) - fpath = self.url2file(url) + print(f'path_call():{path=}, {url=}, {fpath=}') processor = self.url2processor(request, url, fpath) return await processor.path_call(request, params=params) diff --git a/ahserver/url2file.py b/ahserver/url2file.py index 543456f..c139cc6 100644 --- a/ahserver/url2file.py +++ b/ahserver/url2file.py @@ -33,6 +33,7 @@ class Url2File: return real_path def url2file(self, url: str) -> str: + ourl = url url = url.split('?')[0] real_path = self.url2ospath(url) if os.path.isdir(real_path): @@ -45,11 +46,11 @@ class Url2File: return real_path if not os.path.isdir(os.path.dirname(real_path)): - print(f'url2file() return None, {real_path:}') + print(f'url2file() return None, {real_path=}, {url=},{ourl=}, {self.path=}') return None if not self.inherit: - print(f'url2file() return None, self.inherit is false') + print(f'url2file() return None, self.inherit is false, {url:}, {self.path=}') return None items = url.split('/') @@ -57,7 +58,7 @@ class Url2File: del items[-2] url = '/'.join(items) return self.url2file(url) - print(f'url2file() return None finally, {items:}') + print(f'url2file() return None finally, {items:}, {url=}, {ourl=}, {self.path=}') return None def relatedurl(self,url: str, name: str) -> str: