[ZODB-Dev] Objects containing references to other objects

Andrew Kuchling akuchlin@mems-exchange.org
Tue, 5 Jun 2001 09:54:00 -0400


On Tue, Jun 05, 2001 at 08:19:27AM -0400, Jeff Kowalczyk wrote:
>If you have an object (say "person") who might have other objects of
>various classes (other person, appointment, purchaseorder, todo, etc.)
>that should be linked to them in some way, what does a ZDB user
>typically do?

In our application we just keep multiple references to an object.  For
example, if you want a given User object, there's a UserDatabase
object with a get_user() method.  Objects such as ProcessRuns that
have an owner simply have a .owner attribute that's another reference
to the user object.  For example, you assign an owner to a run in the
straightforward way:

run.owner = user_db.get_user('amk')

We don't ever delete data, so we don't really care about creating
cycles; I don't know if cycles are properly garbage-collected in the
ZODB, but you could probably figure that out with a little test
program.

--amk