[sqlalchemy] ORM Event

2011-08-25 Thread Jaimy Azle
Hi, I found some weird case on using the mapper event, i setup the mapper to firing after_insert and after_delete event. However i find some issue, at least weird behaviour: * after_insert and after_delete triggered only once on each committed transaction. dt_1 = Detail(1, 1, 'This is

Re: [sqlalchemy] ORM Event

2011-08-25 Thread Michael Bayer
The Session is not usable in the way you're using it inside of after_insert and after_delete - in particular the modifications made to the state of the object that was just inserted will be discarded, and the add() will have no effect as the flush plan cannot be changed in these events. To

Re: [sqlalchemy] ORM Event

2011-08-25 Thread Jaimy Azle
On Thursday, August 25, 2011, 7:36:53 PM, Michael Bayer wrote: Thanks Michael, The Session is not usable in the way you're using it inside of after_insert and after_delete - in particular the modifications made to the state of the object that was just inserted will be discarded, and the

Re: [sqlalchemy] ORM Event

2011-08-25 Thread Michael Bayer
On Aug 25, 2011, at 10:22 AM, Jaimy Azle wrote: On Thursday, August 25, 2011, 7:36:53 PM, Michael Bayer wrote: Thanks Michael, The Session is not usable in the way you're using it inside of after_insert and after_delete - in particular the modifications made to the state of the object

Re: [sqlalchemy] ORM Event

2011-08-25 Thread Jaimy Azle
On Thursday, August 25, 2011, 11:44:48 PM, Michael Bayer wrote: I would ask why you believe that's true - from what I can tell, you're using the Session.add() or something as a means to test that the event is triggered, which as I mentioned will have side effects. A proper test as below