[ZODB-Dev] List of modified objects
Rad Widmer
rwidmer at eclypse.org
Fri Dec 3 18:09:39 EST 2004
Maybe this is related -- In my application I need to determine whether a transaction has *any*
modified objects. At this time, I don't care what those objects are, I just need to know that there
are some. For example, there is a Save button on the toolbar that I want to enable only if there is
something to be saved. Also, when the user tries to quit the application, it's handy to know if
there are unsaved objects so a prompt can be displayed (save/abandon changes). Since I'm using the
latest version of ZODB, I found that checking the connections's _needs_to_join attribute
periodically works for this.
Rad Widmer
----- Original Message -----
From: "Tim Peters" <tim at zope.com>
To: "'Syver Enstad'" <syver at inout.no>
Cc: <zodb-dev at zope.org>
Sent: Friday, December 03, 2004 1:37 PM
Subject: RE: [ZODB-Dev] List of modified objects
> [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?
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list - ZODB-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zodb-dev
>
>
More information about the ZODB-Dev
mailing list