fix: add util module, w/ model_transaction_query()
just a basic implementation, will have to improve later
This commit is contained in:
parent
0e25cca0ba
commit
4db3fa5962
9 changed files with 281 additions and 13 deletions
|
|
@ -45,7 +45,28 @@ class WuttaContinuumConfigExtension(WuttaConfigExtension):
|
|||
key = "wutta_continuum"
|
||||
|
||||
def startup(self, config): # pylint: disable=empty-docstring
|
||||
""" """
|
||||
"""
|
||||
Perform final configuration setup for app startup.
|
||||
|
||||
This will do nothing at all, unless config enables the
|
||||
versioning feature. This must be done in config file and not
|
||||
in DB settings table:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[wutta_continuum]
|
||||
enable_versioning = true
|
||||
|
||||
Once enabled, this method will configure the integration, via
|
||||
these steps:
|
||||
|
||||
1. call :func:`sqlalchemy-continuum:sqlalchemy_continuum.make_versioned()`
|
||||
2. call :meth:`wuttjamaican:wuttjamaican.app.AppHandler.get_model()`
|
||||
3. call :func:`sqlalchemy:sqlalchemy.orm.configure_mappers()`
|
||||
|
||||
For more about SQLAlchemy-Continuum see
|
||||
:doc:`sqlalchemy-continuum:intro`.
|
||||
"""
|
||||
# only do this if config enables it
|
||||
if not config.get_bool(
|
||||
"wutta_continuum.enable_versioning", usedb=False, default=False
|
||||
|
|
@ -60,14 +81,17 @@ class WuttaContinuumConfigExtension(WuttaConfigExtension):
|
|||
)
|
||||
plugin = load_object(spec)
|
||||
|
||||
# tell sqlalchemy-continuum to do its thing
|
||||
app = config.get_app()
|
||||
if "model" in app.__dict__:
|
||||
raise RuntimeError("something not right, app already has model")
|
||||
|
||||
# let sqlalchemy-continuum do its thing
|
||||
make_versioned(plugins=[plugin()])
|
||||
|
||||
# nb. must load the model before configuring mappers
|
||||
app = config.get_app()
|
||||
model = app.model # pylint: disable=unused-variable
|
||||
# must load model *between* prev and next calls
|
||||
app.get_model()
|
||||
|
||||
# tell sqlalchemy to do its thing
|
||||
# let sqlalchemy do its thing
|
||||
configure_mappers()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue