[Zope] beginner's question: references

Evan Simpson evan@digicool.com
Mon, 6 Mar 2000 10:01:53 -0500


----- Original Message -----
From: Perrin Harkins <perrin@primenet.com>
> This is such a stupid question, but I can't seem to figure it out from
> the docs.  How do I make an object in Zope reference another object?

Not a stupid question, and not simple, either.  There are two ways to do it,
and choosing one over the other can be difficult.

1. Store the absoulte_url() of the referenced object, and run this through a
dereferencing method whenever you want to grab it.

Advantages:  If you really want a reference to a *location*, as opposed
to a specific object, this is the way to go.  That is, if you might delete
or
move the object, replace it with another one with the same name, and
expect the reference to refer to the new object, do this.

Disadvantages:  If you expect the reference to follow the object around
if it's renamed, don't do this.  It has to climb up the path to the object
instead of just grabbing it directly

2.  Store the object as an attribute of the referencing object.  This has to
be done (I think) from an External Method, since you *aren't* setting a
property.  You do something like "self.fooref = self.path.to.other.aq_base"
which DTML doesn't allow.

Advantages & Disadvantages: The inverse of #1

Cheers,

Evan @ digicool & 4-am