Le jeudi 30 août 2012 17:16:40 UTC+2, Michael Bayer a écrit :
def after_flush(session, flush_context):
my_bs = figure_out_bs(session)
new_session = Session(bind=session.connection())
new_session.add_all(my_bs)
# this won't actually
Hi there !
I'm going mad looking for a solution for what seems a simple problem.
When object A is updated, I also want object B to be updated, using some
computation based on A new values.
From now, I can detect when A is modified using after_update.
What I try is to look at event
On Aug 30, 2012, at 10:32 AM, Tony Moutaux wrote:
Hi there !
I'm going mad looking for a solution for what seems a simple problem.
When object A is updated, I also want object B to be updated, using some
computation based on A new values.
From now, I can detect when A is modified using
Only if some computation based on A new values means that there are
SQL-level functions which you need to get at, does the rationale for
after_update/after_flush events to come up.Unfortunately you can't
emit a flush() within any of these events, as they are already local to the
On Aug 30, 2012, at 11:12 AM, Tony Moutaux wrote:
2.if some computation involves SQL functions:
a. emit your modifications to B using only SQL statements and
Session.execute(), not by adding any new state to the Session or re-flushing.
b. pre-execute your SQL functions for A