Michael, Thanks for the response. I ended up going an entirely different route. The details are here: http://stackoverflow.com/questions/15642286/how-can-i-get-a-sqlalchemy-orm-objects-previous-state-after-a-db-update
But the short of it is: 1. I used 'after_flush' as those sessions have the objects with all the data I need. 2. Then I used session.new and session.dirty to get the objects in question. 3. And then I used attribute_state.history to get the old values, which are always present for updates as I read by primary key before running the update. 4. For the create events I don't need the history. Thanks again. On Tuesday, March 26, 2013 4:24:07 PM UTC-4, Evan Hammer wrote: > > I'd like to get notified (either by checking the session or through an > event handler) when an attribute changes value. None of the options I've > figured out so far work for this. Thanks for the help! > > *Event Handler* > event.listen(Object.attribute, 'set', event_handler) > this method fires before the Object gets all the attributes from the > database so the Object isn't really usable. > > > *Session.Dirty* > session.dirty: I can check the updated object before I commit it but I > can't figure out a way to get the oldvalue here. history doesn't seem to > provide an access point. > for o in session.dirty: > if o.is_modified(): > inspect(o).attrs.attribute.history > > > SQLAlchemy==0.8.0b2 > postgres (PostgreSQL) 9.2.3 > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
