On 6/24/15 10:03 AM, Mattias Lagergren wrote:
Hi guys,
I'm trying to retrieve modified (new, deleted and dirty) instances
from the session, before commit but after a flush.
Example:
|
# Update and create objects.
...
|# This is fine and I have my dirty instances:
||print||||session.dirty|||, session.new, session.deleted
session.flush()
||
|||# At this point each set is empty:
||print session.dirty|||, session.new, session.deleted||
session.commit()
|
It seems like the finalize_flush_changes
<http://docs.sqlalchemy.org/en/rel_0_9/orm/internals.html#sqlalchemy.orm.session.UOWTransaction.finalize_flush_changes>
is called when flushing remove the objects from the session new, dirty
and deleted.
Is there any way I can retrieve those changes after flush but before
commit?
yes use the after_flush() event:
http://docs.sqlalchemy.org/en/rel_1_0/orm/events.html?highlight=after_flush#sqlalchemy.orm.events.SessionEvents.after_flush
I'm using SqlAlchemy 0.9.7
Thanks!
Mattias L
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.