get_history() is a public function within the attributes package at the top level, and I also added API documentation for it recently (not on the site yet).
from sqlalchemy.orm.attributes import get_history, instance_state get_history(instance_state(myobject), "someattribute") in the latest trunk you can pass "myobject" straight to get_history without using instance_state. session.is_modified() just calls get_history() on every attribute, so you might want to consider just looping through the attributes the way is_modfied() does and do your history operation inline. On Feb 18, 2009, at 9:43 AM, kindly wrote: > > Hello > > I intend to log any changes (not new rows) to a table. > > The simplist way I can see to do this is to check every object that is > "add"ed for changes. I intend to, before every flush, look in "dirty" > then use is_modified and if there is a change use get_history to find > out the original and new attribute values. I am wary of doing it this > way as _sa_instance_state looks private even though get_history is > not. Should this be safe to use? Or is there a better way? > > Thanks > > David > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---