mitsuhiko/flask-sqlalchemy — Issue #64: use of partial() in create_scoped_session prevents SQLAlchemy.session from being used with SQL Alchemy event listeners
Author: nathan-rice
Created: 2011-12-01 20:20:57+00:00
State: open

SQL Alchemy events are registered by calling the listen function with a class, an event name and a function. By returning a partial, you make it difficult to attach listeners. I suppose you could work around this issue by calling type(db.session()), however a decent amount of debugging is required to figure out why things don't work in the first place.

A simple solution is to create a singalling_session_maker function that takes the same arguments as signalling_session, then define _SignallingSession inside this function with a reduced __init__ function, and return it. Then you can just call that factory inside of scoped_session().