[Zope-dev] ZODB Competing read/writes: How to find out which attribute?

Shane Hathaway shane at hathawaymix.org
Sat Oct 10 22:00:42 EDT 2009


Hermann Himmelbauer wrote:
> That's exactly the problem - it's a read operation and there should not be any 
> write operation involved. However, it's hard to find out where the write 
> operation in my code occurs, I can't find it in the view, maybe there's 
> something in the authentication code, but I'd have to dig deep through my 
> source. So It would be extremely helpful to know a faster way to find out 
> what code triggered this warning.

The code that modifies something will indirectly call the register() 
method of the ZODB.Connection class.  If you arrange for 
Connection.register() to raise an exception when the transaction is not 
supposed to modify anything, you should get a traceback that pinpoints 
what is doing the modification.  Unfortunately, there is no API for 
that, so the easiest thing to do is modify the source code of the 
register() method in ZODB.Connection.  Fortunately, this is Python, so 
modifying someone else's code is usually quite easy. :-)

Shane



More information about the Zope-Dev mailing list