From c2141c776b650270a7d182672c109928e007301e 2024-09-08 19:40:34 From: Lance Edgar Date: 2024-09-08 19:40:34 Subject: [PATCH] docs: update comment for startup versioning workaround now that i know a *little* more about why it is needed --- diff --git a/rattail/config.py b/rattail/config.py index 3db51d9b397473b9ec57931464df968744f12cd7..1a625cb7963a95f759d7a770dea60cbab015e1e6 100644 --- a/rattail/config.py +++ b/rattail/config.py @@ -779,11 +779,11 @@ 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.. + # must import all sqlalchemy models before things get rolling, + # otherwise can have errors about continuum TransactionMeta + # class not yet mapped, when relevant pages are first requested + # cf. https://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/database/sqlalchemy.html#importing-all-sqlalchemy-models + # hat tip to https://stackoverflow.com/a/59241485 if getattr(config, 'trainwreck_engines', None): app = config.get_app() trainwreck = app.get_trainwreck_handler()