[Zope-dev] Efficient and flexible object references

Michael R. Bernstein webmaven@lvcm.com
17 Aug 2001 22:46:51 -0700


On 17 Aug 2001 23:50:53 -0400, Gary & Karyn wrote:
> [Originally posted on the main Zope list.  Moving it here on recommendation
> for a deeper discussion.]
> 
> Hello.
> 
> I am building a Zope application (described more in full at the end of the
> message, eliminated here for brevity) that needs to make a large number of
> object references from other objects.

Wow. that really takes me on a ride in the Wayback Machine... I had
similar thoughts once upon a time, but never pursued them:

http://classic.zope.org/pipermail/zope/1999-November/013860.html

I think that two of the approaches you listed can be hybridized to give
you what you want.

First, give your objects globally unique ids, according to some schema
that you create (ie 'comp0000000000023').

Next, store the globally unique id as a reference to the object in the
referring object.

Then, catalog the referred object, making sure that the id is indexed
(probably as a field index), and store any meta data that you want the
referring objects to retrieve.

The referring object can just query the ZCatalog using the guid to get
the result object, along with any cached meta-data, without waking the
referred object.

Updating the catalog changes the rid, but that doesn't matter since
you're retreiving the object from the catalog using a guid (which
shouldn't change).

Finally, catalog the referring object as well, indexing the field
storing the referred objects guid. Thus the referred object can also
query the catalog to get a result-set of the objects that refer to it,
along with appropriate meta-data.

Does this help?

Michael Bernstein.