From 666854a198047db7eeea3949b435d3fec9237f37 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 23 Oct 2025 22:52:56 +0800 Subject: [PATCH] bugfix --- ahserver/dbadmin.py | 57 ----------------------------------- ahserver/processorResource.py | 32 -------------------- 2 files changed, 89 deletions(-) delete mode 100644 ahserver/dbadmin.py diff --git a/ahserver/dbadmin.py b/ahserver/dbadmin.py deleted file mode 100644 index 2073823..0000000 --- a/ahserver/dbadmin.py +++ /dev/null @@ -1,57 +0,0 @@ -import os -import re -import traceback - -from aiohttp.web_response import Response -from aiohttp.web_exceptions import ( - HTTPException, - HTTPExpectationFailed, - HTTPForbidden, - HTTPMethodNotAllowed, - HTTPNotFound, -) -from aiohttp import web -from aiohttp.web_request import Request -from aiohttp.web_routedef import AbstractRouteDef -from aiohttp.web import json_response - - -from sqlor.crud import CRUD - -from appPublic.dictObject import multiDict2Dict -from appPublic.jsonConfig import getConfig -from appPublic.log import info, debug, warning, error, critical, exception - -from .error import Error,Success -actions = [ - "browse", - "add", - "update", - "filter" -] - -class DBAdmin: - def __init__(self, request,dbname,tablename, action): - self.dbname = dbname - self.tablename = tablename - self.request = request - self.action = action - if action not in actions: - debug('action not defined:%s' % action) - raise HTTPNotFound - try: - self.crud = CRUD(dbname,tablename) - except Exception as e: - exception('e= %s' % e) - traceback.print_exc() - raise HTTPNotFound - - async def render(self) -> Response: - try: - d = await self.crud.I() - return json_response(Success(d)) - except Exception as e: - exception('except=%s' % e) - traceback.print_exc() - return json_response(Error(errno='metaerror',msg='get metadata error')) - diff --git a/ahserver/processorResource.py b/ahserver/processorResource.py index bc10a08..759a1c6 100644 --- a/ahserver/processorResource.py +++ b/ahserver/processorResource.py @@ -56,7 +56,6 @@ from .serverenv import ServerEnv from .url2file import Url2File from .filestorage import FileStorage, file_realpath from .restful import DBCrud -from .dbadmin import DBAdmin from .filedownload import file_download, path_decode from .utils import unicode_escape from .filetest import current_fileno @@ -330,37 +329,6 @@ class ProcessorResource(StaticResource,Url2File): path = request.path config = getConfig() request['port'] = config.website.port - if config.website.dbadm and path.startswith(config.website.dbadm): - pp = path.split('/')[2:] - if len(pp)<3: - error('%s:not found' % str(request.url)) - raise HTTPNotFound - dbname = pp[0] - tablename = pp[1] - action = pp[2] - adm = DBAdmin(request,dbname,tablename,action) - return await adm.render() - if config.website.dbrest and path.startswith(config.website.dbrest): - pp = path.split('/')[2:] - if len(pp)<2: - error('%s:not found' % str(request.url)) - raise HTTPNotFound - dbname = pp[0] - tablename = pp[1] - id = None - if len(pp) > 2: - id = pp[2] - crud = DBCrud(request,dbname,tablename,id=id) - return await crud.dispatch() - if config.website.download and path.startswith(config.website.download): - pp = path.split('/')[2:] - if len(pp)<1: - error('%s:not found' % str(request.url)) - raise HTTPNotFound - dp = '/'.join(pp) - path = path_decode(dp) - return await file_download(request, path) - processor = self.url2processor(request, str(request.url), self.request_filename) if processor: ret = await processor.handle(request)