[Zope] Conflict error
Miles
miles at jamkit.com
Fri Mar 20 17:17:58 EDT 2009
Hi,
Thanks Tres. I got to the bottom of what was happening.
An attribute was being renamed "transparently" using the following code:
def getConnection(self):
if getattr(self, '_connection', None):
self.db_connection = self._connection
return self.db_connection
Obviously, this fires every time getConnection is called, setting the
attribute and therefore making the database commit. For reference, it
should have been:
def getConnection(self):
if getattr(self, '_connection', None):
self.db_connection = self._connection
delattr(self, '_connection')
return self.db_connection
This only commits to the database once.
Also out of interest, I found a handy way to find out what was going on,
that I haven't come across previously, that might be of interest:
>>> app._p_jar._registered_objects
[]
>>> component.getConnection()
>>> app._p_jar._registered_objects
[MyComponent.MyComponent]
>>> app._p_jat._registered_objects[0].__dict__
{....}
Basically I used it to work out which call caused the object to register
with the transaction. In this case, there were only a couple of methods
that got called, so it was more to verify it didn't get registered any
more (the test case was "intermittent", i.e. only for the client :-/ ).
Anyway, might be useful for someone,
Cheers,
Miles
More information about the Zope
mailing list