On Sep 28, 2007, at 5:22 PM, Jonathan LaCour wrote:
>
> Michael Bayer wrote:
>
>> however, the column-based attributes present on the instance itself
>> have not yet been inserted/updated into the DB, and the fact that
>> the instance is being sent to before_update() indicates that it has
>> in fact already been marked as "dirty" and is to be updated. So
>> whatever column-attribute changes you make within before_update to
>> the
>> local instance will be reflected in the immediately proceeding SQL
>> statement.
>
> Is there any way to determine why an object as been marked as dirty by
> asking the session? The reason I ask is because sometimes objects
> which
> have had none of their column-based attributes modified are marked as
> dirty as the result of something that has happened on a relation. It
> would be nice to know in my before_update() *why* the object is dirty
> without having to query the database for the current column values and
> do comparisons.
>
> Just curious if this is possible...
i just added it to before_update's docstring today:
session.is_modified(instance, include_collections=False)
and you can get the session using object_session(instance).
I know this is relevant to your versioning extension since Ben and I
had a day of it last week .... :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---