[Zope-dev] circular referenced persistent objects

zope at netchan.cotse.net zope at netchan.cotse.net
Sat Apr 10 15:11:56 EDT 2004


I have the following setup (unrelated lines are omitted):

class Deliverer(Folder):
    def manage_afterAdd(self, item, container):
        if item is self:
            self.__ac_local_roles__ = dr_localroles(self)

class dr_localroles(Persistent):
    def __init__(self, dr):
        self.dr = dr

dr_localroles implements a few methods of the dictionary interface, so I
can always check the effective settings via the Security/local roles zmi
page. In order to computing roles, dr_localroles requires its parent
object instance (Deliverer), that's why I store a reference to it as an
attribute.
Question:
 - Is there a way for dr_localroles to refer its parent without holding
a reference to it or using weak reference?
 - Is there an equivalent of sys.getrefcount for ZODB persistent
objects?

Also a note for the archives:
I wanted to make sure that if I delete a Deliverer object, it will
indeed be removed from ZODB. For this I got the oid of the object,
deleted it and than tried to get it back via the oid. The trick is, that
you'll only get a POSKeyError if you pack the database and flush the
cache. This latter one was not obvious for me.

Reagards,
Sandor








More information about the Zope-Dev mailing list