[ZODB-Dev] List of modified objects

Tim Peters tim at zope.com
Fri Dec 3 14:37:07 EST 2004


[Syver Enstad]
> Somewhat related would be my wish for a hook called on commit of the
> transaction which would allow objects to register certain information, in
> my case a timestamp for the commit time and the name of the user making
> the change. I use __getstate__ for this today but that seems like a hack.

I expect you first need to be more precise about what a suitable API would
look like, and what it would do.  Presumably an API that iterated over the
modified objects would not be suitable for you, since that's what was being
discussed originally, and you're writing as if that's not what you want.

Then Jeremy's guess about what you might want caused him to say it already
exists, citing the registerSynch() method of transaction managers in ZODB
3.3.  That easily supports adding a note and user name to a *transaction* at
commit time, but it sounds more like you want to add data to each individual
changed object.  So I don't think Jeremy's guess was right either (there's
no documented way to get from a transaction object to the objects modified
in that transaction).

OTOH, *if* transactions grew an API to iterate over changed objects, *then*
regsisterSynch() could be used to get your own function triggered before a
commit, your function would be passed the Transaction object, and it could
use the hypothetical iterate-over-changed-objects API to do whatever it
liked to modified objects before they were committed.  Would that suffice?



More information about the ZODB-Dev mailing list