diff --git a/rattail/config.py b/rattail/config.py index 427763391dec7f87acb70b7b9cb4d5c18dae5c71..3db51d9b397473b9ec57931464df968744f12cd7 100644 --- a/rattail/config.py +++ b/rattail/config.py @@ -779,29 +779,29 @@ def make_config( from rattail.db.config import configure_versioning configure_versioning(config) + # TODO: holy crap why is this needed? without it, the first time + # a trainwreck query happens, InvalidRequestError is raised. but + # this is clearly a trainwreck query, and yet no error if we do it + # this early in the startup sequence?! i have no idea what is + # going on here but at least this "works" - fingers crossed.. + if getattr(config, 'trainwreck_engines', None): + app = config.get_app() + trainwreck = app.get_trainwreck_handler() + try: + trainwreck_model = trainwreck.get_model() + except WuttaConfigurationError: + pass + else: + trainwreck_session = trainwreck.make_session() + trainwreck_session.query(trainwreck_model.Transaction).first() + trainwreck_session.close() + # maybe set "future" behavior for SQLAlchemy if config.get_bool('rattail.db.sqlalchemy_future_mode', usedb=False): from rattail.db import Session if Session: Session.configure(future=True) - # TODO: holy crap why is this needed? without it, the first time - # a trainwreck query happens, InvalidRequestError is raised. but - # this is clearly a trainwreck query, and yet no error if we do it - # this early in the startup sequence?! i have no idea what is - # going on here but at least this "works" - fingers crossed.. - if getattr(config, 'trainwreck_engines', None): - app = config.get_app() - trainwreck = app.get_trainwreck_handler() - try: - trainwreck_model = trainwreck.get_model() - except WuttaConfigurationError: - pass - else: - trainwreck_session = trainwreck.make_session() - trainwreck_session.query(trainwreck_model.Transaction).first() - trainwreck_session.close() - return config