[Sqlalchemy-tickets] Issue #3637: Add to SQLAlchemy Session in before_flush event? (zzzeek/sqlalche
Brought to you by:
zzzeek
|
From: Roman D. <iss...@bi...> - 2016-01-22 07:33:51
|
New issue 3637: Add to SQLAlchemy Session in before_flush event? https://bitbucket.org/zzzeek/sqlalchemy/issues/3637/add-to-sqlalchemy-session-in-before_flush Roman D.: Is there a proper way to add new object to Session while in before_flush event without infinite loop? Example: ``` #!python from sqlalchemy import event @event.listens_for(SomeSessionOrFactory, 'before_flush') def receive_before_flush(session, flush_context, instances): session.add(NEW_OBJECT) ``` I'm trying to make logging system for all models. Maybe there is a better way to do this? :) |