[Zope-dev] Pointer or reference object

Itamar Shtull-Trauring itamars@ibm.net
Sun, 05 Mar 2000 10:43:20 +0200


Jason Spisak wrote:

> This is very out of the blue, but has anyone thought about tackling the
> 'reference' question by using a phantom Zope object?  I don't know
> nearly enough Python to answer this question, but maybe someone can.
> 
> Is it possible to create a 'Reference' object that really stores the url
> of another object and maquerades as the other object's meta_type.
> Anything that is asked of the 'Reference' object, just get's passed
> along to the real object in it's place?  Obviously whenever you delete
> an object any 'References' with that object's url stored in them get
> deleted too(ZCatalog could hold these).  Sort of like a reflective
> mirror.  You see the object in the mirror but you aren't actually
> looking at the object, you are looking at the mirror.  A ZMirror.

We do this by giving each object an unique id, which is cataloged in a
ZCatalog.  A Link object stores the objects' uid and URL, and had a method
get_linkObject that returns the linked object.  First it checks if the
object at the stored url has the correct uid, and if not it searches the
zcatalog for it.  It doesn't masquerade as another object, but you can use
it to get at the linked object.
 
-- 
                -=  This is NOT a pyramid scheme  =-
The SNAFU Principle: True communication is possible only between equals

                      Itamar S.T.  itamars@ibm.net