[Grok-dev] References in ZODB

Martijn Faassen faassen at startifact.com
Sun Aug 8 11:28:31 EDT 2010

On 08/07/2010 11:37 AM, Achim Domma wrote:
> I try to store hierarchical geo data about places into a ZODB.
> Because each place has a unique ID which will be used to access them,
> I have stored the place instances in a persistent dictionary. Now
> want to store the relation between places, i.e. the children of a
> place. At the moment I store the IDs of the children, not the
> children themselves. According to
> http://faassen.n--tree.net/blog/view/weblog/2008/06/20/0
> storing the children themselves should be no problem. Is that right?

That shouldn't be a problem. Whether it is the right design for your 
data model is another question, of course - sometimes it's useful to 
store a relation as a separate object, for instance.

> A bigger cause for concern are neighbors: If two places are neighbors
> they would hold a reference to each other. In other languages this
> might cause trouble, so I wanted to ask, before doing stupid things!
> ;-)

In ZTK/Grok we have such circular references all the time: a container 
contains children which contain pointers to its __parent__. So this 
ought to be okay.

> Is it ok to use real objects instead of ids in the above scenario? Or
> will it cause trouble if I create circles in objects referencing each
> other?

I don't think there's an issue with circular references.

I'll note one thing that might affect the design of your application. In 
case you want to be able to do queries on references, you should take a 
look at zc.relation:


In case you use forms and schemas, you might want to consider this:


which is built with zc.relation.



More information about the Grok-dev mailing list