Add to SQLAlchemy Session in before_flush event?
Issue #3637
resolved
Is there a proper way to add new object to Session while in before_flush event without infinite loop?
Example:
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? :)
Comments (3)
-
repo owner -
repo owner -
reporter - changed status to resolved
My mistake. Everything works great.
- Log in to comment
no infinite loop is implicit in this activity. Feel free to provide an actual demonstration of your issue per the guidelines at http://stackoverflow.com/help/mcve. Here's a demo, thanks!