[Zope] Zope leaking memory?

Alec Mitchell apm13 at columbia.edu
Mon Sep 13 18:22:34 EDT 2004


On Monday 13 September 2004 01:52 pm, Chris McDonough wrote:
> On Mon, 2004-09-13 at 16:28, Alec Mitchell wrote:
> > Is this the case even for subtransaction commits?
>
> Yes, subtransaction commits are actually even more dangerous in current
> Zopes than regular transaction commits due to an obscure bug in ZODB in
> all versions prior to 2.7.3.
>
Oh no!

> But they're really only dangerous if you (or someone using your code)
> inappropriately catches an exception during one of the commits.
> Inappropriately catching exceptions raised by a transaction commit is a
> pretty good way to get inconsistent app state in your database.  See the
> ZODB-dev thread for more info.
>
Fortunately that shouldn't happen here.  Do you mean that only something like 
a bare except: that doesn't re-raise the exception would cause a problem.  
There are no exceptions explicitly caught in my code, but there are calls to 
Zope/Plone/CMF methods which may cause issues.  In particular the setId call 
from Archetypes calls aq_parent(self).manage_renameObject() which has a bare 
except, though that just raises a CopyError.

> > I have a particular piece
> > of code that adds a new piece of content to a CMF Site programmatically
> > as the result of a TTW action.  During the course of adding the content
> > setId() is called on the object, which fails consistently unless a
> > subtransaction is committed prior to the call (I believe the issue was
> > that the created object wasn't yet stored in the ZODB, so calling setId
> > (which causes a copy) failed).
>
> Can you call setId on it after its attached to another persistent object
> instead of trying to call setId on it while it's "bare"?  But..
> actually, why does setId cause a copy?  setId seems pretty innocuous at
> least in name ;-)

As above, the setId for Archetypes renames the object using 
OFS.CopySupport.manage_renameObject(), which causes a copy and delete.  How 
would I attach the object to another persistent object during the 
transaction?  Also, why isn't it already attached to the containing folder 
after being created using self.manage_addProduct[ProductName].addType, where 
self is the containing folder.  Do I explicitly need to do a 
self._setObject() before the setId call?  Or do I need to explicitly 
acquisition wrap the new object?  Thanks in advance.

Alec Mitchell


More information about the Zope mailing list