fix: businessdate DBPools()缺config导致backend_accounting报NoneType
This commit is contained in:
parent
cec6e43397
commit
5e7bdc5c2e
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user