diff --git a/uapi/appapi.py b/uapi/appapi.py index e764ea3..a342375 100644 --- a/uapi/appapi.py +++ b/uapi/appapi.py @@ -1,6 +1,7 @@ from functools import partial from sqlor.dbpools import DBPools from appPublic.httpclient import JsonHttpAPI +from appPublic.log import debug, exception, from ahserver.globalEnv import password_decode from aiohttp import web @@ -50,17 +51,21 @@ where if rec.need_auth and self.auth_api is None: self.auth_api = await self.get_authapi(sor) if rec.need_auth and self.auth_api is None: - raise Exception(f'{rec.appname} app has not auth api but need') + e = Exception(f'{rec.appname} app has not auth api but need') + exception(f'{e=}, {format_exc()}') + raise e rec.auth_api = self.auth_api rec.apikey_orgid = orgid return recs[0] return None - def request(self, apiname, ns): + async def request(self, apiname, ns): orgs = ns.get('orgs') api = await self.get_apiinfo(orgs, apiname) if api is None: - raise Exception(f'{self.appid} app has not {apiname} api') + e = Exception(f'{self.appid} app has not {apiname} api') + exception(f'{e=}, {format_exc()}') + raise e ns1 = self.env.copy() ns1['apikey'] = api.apikey ns1['secretkey'] = api.secretkey @@ -76,7 +81,9 @@ where datatmpl=self.auth_api.data, resptmpl=self.auth_api.response) if self.auth_ret is None: - raise Exception(f'{self.appid} app auth error') + e = Exception(f'{self.appid} app auth error') + exception(f'{e=}, {format_exc()}') + raise e ns1.update(self.auth_ret) stream_func = None if api.stream: diff --git a/uapi/init.py b/uapi/init.py index 9ac8346..0c585c4 100644 --- a/uapi/init.py +++ b/uapi/init.py @@ -1,4 +1,4 @@ -from ahserver.serverenv import get_serverenv +from ahserver.serverenv import ServerEnv from .appapi import AppAPI, AiohttpAppAPI def load_uapi():