bugfix
This commit is contained in:
parent
095ae28210
commit
5470d3be33
@ -31,13 +31,14 @@ async def sync_users(request, upappid, userid):
|
|||||||
upapp = await get_upapp(sor, upappid)
|
upapp = await get_upapp(sor, upappid)
|
||||||
|
|
||||||
class UAPI:
|
class UAPI:
|
||||||
def __init__(self, request, env=DictObject()):
|
def __init__(self, request, env=DictObject(), sor=None):
|
||||||
self.request = request
|
self.request = request
|
||||||
self.te = MyTemplateEngine([], env=env)
|
self.te = MyTemplateEngine([], env=env)
|
||||||
self.env = env
|
self.env = env
|
||||||
self.env.request.request = request
|
self.env.request.request = request
|
||||||
self.auth_api = None
|
self.auth_api = None
|
||||||
self.auth_ret = None
|
self.auth_ret = None
|
||||||
|
self.sor = sor
|
||||||
|
|
||||||
async def rendertmpl(self, tmplstr, params={}):
|
async def rendertmpl(self, tmplstr, params={}):
|
||||||
if tmplstr is None:
|
if tmplstr is None:
|
||||||
@ -47,13 +48,15 @@ class UAPI:
|
|||||||
te = MyTemplateEngine([], env=self.env)
|
te = MyTemplateEngine([], env=self.env)
|
||||||
return te.renders(tmplstr, ns)
|
return te.renders(tmplstr, ns)
|
||||||
|
|
||||||
async def get_uapis(self, upappid, apiname, callerid, params={}):
|
async def get_uapis(self, sor, upappid, apiname, callerid, params={}):
|
||||||
self.env.update(params)
|
self.env.update(params)
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_dbname()
|
|
||||||
uapi = None
|
uapi = None
|
||||||
auth_uapi = None
|
auth_uapi = None
|
||||||
async with db.sqlorContext(dbname) as sor:
|
if self.sor is None:
|
||||||
|
dbname = get_dbname()
|
||||||
|
self.sor = db.sqlorContext(dbname)
|
||||||
|
async with self.sor as sor:
|
||||||
upapps = await sor.R('upapp', {'id': upappid})
|
upapps = await sor.R('upapp', {'id': upappid})
|
||||||
if len(upapps) == 0:
|
if len(upapps) == 0:
|
||||||
e = Exceptions(f'{upappid=}, {apiname=}, {callerid=} upapp not found')
|
e = Exceptions(f'{upappid=}, {apiname=}, {callerid=} upapp not found')
|
||||||
@ -92,8 +95,18 @@ class UAPI:
|
|||||||
async def __call__(self, upappid, apiname, callerid, params={}):
|
async def __call__(self, upappid, apiname, callerid, params={}):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
auth_uapi, uapi = await self.get_uapis(upapiid, apiname,
|
auth_uapi = uapi = None
|
||||||
|
if self.sor:
|
||||||
|
auth_uapi, uapi = await self.get_uapis(self.sor, upapiid, apiname,
|
||||||
callerid, params=params)
|
callerid, params=params)
|
||||||
|
else:
|
||||||
|
dbname = get_dbname()
|
||||||
|
self.sor = db.sqlorContext(dbname)
|
||||||
|
async with self.sor as sor:
|
||||||
|
auth_uapi, uapi = await self.get_uapis(self.sor,
|
||||||
|
upapiid, apiname,
|
||||||
|
callerid, params=params)
|
||||||
|
|
||||||
if uapi is None:
|
if uapi is None:
|
||||||
return
|
return
|
||||||
if auth_uapi:
|
if auth_uapi:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user