This commit is contained in:
yumoqing 2021-12-30 10:37:06 +08:00
parent 6367b545ba
commit cd6be234de

View File

@ -1,3 +1,9 @@
import os
import codecs
from aiohttp.web_exceptions import (
HTTPException
)
import ujson as json import ujson as json
from .baseProcessor import BaseProcessor from .baseProcessor import BaseProcessor
from crud_engine.crud_engine import CRUDEngine from crud_engine.crud_engine import CRUDEngine
@ -22,22 +28,17 @@ class CrudProcessor(BaseProcessor):
async def path_call(self, request, params={}): async def path_call(self, request, params={}):
await self.set_run_env(request) await self.set_run_env(request)
dic = {} dic = {}
with codees.open(self.real_path, 'r', 'utf-8') as f: with codecs.open(self.real_path, 'r', 'utf-8') as f:
dic = json.load(f) dic = json.load(f)
x = request.path.split('/') x = request.path.split('/')
if len(x) >= 3: if len(x) >= 2:
act = x[-2] act = x[-2]
if act in [':browser', ':filter', ':add', ':edit', ':delete']: if not CRUDEngine.is_legal_cmd(act):
database = x[-4] act = CRUDEngine.defaultcmd()
table = x[-3]
else:
database = x[-3]
table = x[-2]
act = ':browser'
default_filter_data = self.get_default_filter_data() default_filter_data = self.get_default_filter_data()
ce = CRUDEngine(database, table, dic, default_filter_data) ce = CRUDEngine(self.resource, dic, default_filter_data)
return await ce.dispatch(act) return await ce.dispatch(act)
raise HttpError(500) raise HttpException(555)
async def datahandle(self, request): async def datahandle(self, request):
self.content = await self.path_call(request) self.content = await self.path_call(request)