[Zope-dev] Re: circular referenced persistent objects

Tim Peters tim at zope.com
Mon Apr 12 12:15:53 EDT 2004


[Sandor]
> This is still a question. Is there any way, to determine how many
> times a zodb persistent object is referenced?

ZODB itself doesn't keep track of that, although it's possible to write a
storage that does.  FileStorage does not.  BerkeleyStorage did (past tense
because Zope Corp has given up on BerkeleyStorage for now).

> sys.getrefcount seems to tell me only those references which are
> currently loaded in the memory.

Yes, sys.getrefcount() is a Python builtin, and only knows about in-memory
Python objects.  Python (and its builtins) doesn't know anything about
persistence.

> Also another very interesting question is that who referring
> to a specific object.

Like at the start, it would be possible to write a storage that saves away
that kind of "inverted index", but I don't know of any that do.

Given a particular flavor of storage, and detailed knowledge of its
implementation, you can write scripts to crawl over the storage and compute
anything you like.  For FileStorage, the standard tools fsrefs.py and
fsdump.py illustrate two ways of picking apart an .fs file.




More information about the Zope-Dev mailing list