[ZODB-Dev] List of modified objects

Tim Peters tim at zope.com
Thu Dec 2 09:59:02 EST 2004


[Thomas Guettler]
>>> How can you get the list of all objects which where modified in a
>>> transaction?
>>>
>>> I want to be sure that a read only access does not change anything. The
>>> transaction gets finished with abort(). Before the abort I like to
>>> check if the list of modified objects is empty.

[Christian Robottom Reis]
>> If you don't use subtransactions, it's an easy answer:
>>
>>     connection.getTransaction()._objects
>>
>> If you do, I can't say I know.

Me neither.

[Jim Fulton]
> Of course, because this relies on changable implementation details, it's
> very brittle. For example, this won't work reliably in ZODB 3.3.

In 3.3 it will blow up with AttributeError every time, so it's reliable, it
just doesn't work at all <wink>.

Gloss:  prior to 3.3, transactions keep track of modified objects, with the
oft-noted consequence that a transaction never learns about a connection
that hasn't modified an object.  In 3.3, connections keep track of their own
modified objects, and the connections (not the objects) register with the
transaction.  That's why there's no way to cheat (using private attributes,
neither anything else) that can work across both.

> There isn't a public API for this. I think that there should be.

I'll add it to the ZODB 3.4 wish list.



More information about the ZODB-Dev mailing list