From 5e7bdc5c2e3e8d5194312a5d4e68851945c0ecc8 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 14 Jul 2026 14:15:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20businessdate=20DBPools()=E7=BC=BAconfig?= =?UTF-8?q?=E5=AF=BC=E8=87=B4backend=5Faccounting=E6=8A=A5NoneType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appbase/businessdate.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/appbase/businessdate.py b/appbase/businessdate.py index bb7b7e8..084c45f 100644 --- a/appbase/businessdate.py +++ b/appbase/businessdate.py @@ -1,12 +1,16 @@ from sqlor.dbpools import DBPools from ahserver.serverenv import get_serverenv +from appPublic.jsonConfig import getConfig from appPublic.timeUtils import strdate_add def get_dbname(): f = get_serverenv('get_module_dbname') if f is None: raise Exception('get_module_dbname not found') - dbname = f('appbase') + return f('appbase') + +def _get_db(): + return DBPools(getConfig().databases) async def get_business_date(sor=None): async def _f(sor): @@ -18,9 +22,8 @@ async def get_business_date(sor=None): if sor: return await _f(sor) - db = DBPools() dbname = get_dbname() - async with db.sqlorContext(dbname) as sor: + async with _get_db().sqlorContext(dbname) as sor: return await _f(sor) async def new_business_date(sor=None): @@ -32,9 +35,8 @@ async def new_business_date(sor=None): if sor: return await _f(sor) - db = DBPools() dbname = get_dbname() - async with db.sqlorContext(dbname) as sor: + async with _get_db().sqlorContext(dbname) as sor: return await _f(sor) async def previous_business_date(sor=None): @@ -43,5 +45,4 @@ async def previous_business_date(sor=None): async def next_business_date(sor=None): dat = await get_business_date(sor=sor) - return strdate_add(dat, days=1) - + return strdate_add(dat, days=1) \ No newline at end of file