fix: avoid deprecated function for get_engines() config

This commit is contained in:
Lance Edgar 2024-07-01 22:11:00 -05:00
parent 7dde017c58
commit d2c8274afd

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -26,8 +26,9 @@ Rattail-COREPOS Config Extension
import warnings import warnings
from wuttjamaican.db.conf import get_engines
from rattail.config import ConfigExtension from rattail.config import ConfigExtension
from rattail.db.config import get_engines
class RattailCOREPOSExtension(ConfigExtension): class RattailCOREPOSExtension(ConfigExtension):
@ -45,7 +46,7 @@ class RattailCOREPOSExtension(ConfigExtension):
# office_op # office_op
from corepos.db.office_op import Session from corepos.db.office_op import Session
engines = get_engines(config, section='corepos.db.office_op') engines = get_engines(config, 'corepos.db.office_op')
config.core_office_op_engines = engines config.core_office_op_engines = engines
config.core_office_op_engine = engines.get('default') config.core_office_op_engine = engines.get('default')
Session.configure(bind=config.core_office_op_engine) Session.configure(bind=config.core_office_op_engine)
@ -55,7 +56,7 @@ class RattailCOREPOSExtension(ConfigExtension):
# office_trans # office_trans
from corepos.db.office_trans import Session from corepos.db.office_trans import Session
engines = get_engines(config, section='corepos.db.office_trans') engines = get_engines(config, 'corepos.db.office_trans')
config.core_office_trans_engines = engines config.core_office_trans_engines = engines
config.core_office_trans_engine = engines.get('default') config.core_office_trans_engine = engines.get('default')
Session.configure(bind=config.core_office_trans_engine) Session.configure(bind=config.core_office_trans_engine)
@ -65,9 +66,9 @@ class RattailCOREPOSExtension(ConfigExtension):
# office_arch # office_arch
from corepos.db.office_arch import Session from corepos.db.office_arch import Session
engines = get_engines(config, section='corepos.db.office_arch') engines = get_engines(config, 'corepos.db.office_arch')
if not engines: if not engines:
engines = get_engines(config, section='corepos.db.office_trans_archive') engines = get_engines(config, 'corepos.db.office_trans_archive')
if engines: if engines:
warnings.warn("config section [corepos.db.office_trans_archive] is deprecated; " warnings.warn("config section [corepos.db.office_trans_archive] is deprecated; "
"please use section [corepos.db.office_arch] instead", "please use section [corepos.db.office_arch] instead",
@ -81,7 +82,7 @@ class RattailCOREPOSExtension(ConfigExtension):
# lane_op # lane_op
from corepos.db.lane_op import Session from corepos.db.lane_op import Session
engines = get_engines(config, section='corepos.db.lane_op') engines = get_engines(config, 'corepos.db.lane_op')
config.core_lane_op_engines = engines config.core_lane_op_engines = engines
config.core_lane_op_engine = engines.get('default') config.core_lane_op_engine = engines.get('default')
Session.configure(bind=config.core_lane_op_engine) Session.configure(bind=config.core_lane_op_engine)