Using Versioned Objects recipe with Flask-sqlalchemy
- A B
- 2013-07-05 @ 22:25
I've been trying to get the Sqlalchemy (0.8.1) Versioned Objects recipe (
to work with the flask-sqlalchemy (0.16) extension with no luck.
I've modified my VersionedMeta class with Armin's comments and it now looks
db = SQLAlchemy()
MetaBase = type(db.Model)
def __init__(cls, classname, bases, dict_):
MetaBase.__init__(cls, classname, bases, dict_)
mapper = class_mapper(cls)
The problem I seem to be facing is that the VersionedListener
SessionExtension class never seems to call before_flush. Which is weird
since if I add it [before_flush] to the flask_sqlalchemy.py
- _SignallingSessionExtension class, it works successfully. My impression
was that any extensions added in the call:
db = SQLAlchemy(app, session_extensions=[VersionedListener()])
Would be called before the _SignallingSessionExtension extension. So I'm
not quite sure why it doesn't work from my class.
Ironically this history_meta.py and VersionedListener class is the one used
in the Flask-sqlalchemy session_extensions comment example. So any help in
this matter would be greatly appreciated.