[Zope] String to object ID

Sam Gendler sgendler@teknolojix.com
Mon, 06 Dec 1999 15:23:03 -0800


Goodrichs wrote:

> Well I still don't know how to reference a Zope object from a string, but I
> have a interim solution for now.
>
> I created a method in my root directory called "buildHeader";
>
> <dtml-let newname="(
>         _['root']+'/'+
>         _['prefix']+'/'+
>         _['path']+
>         _['fold'])">
>         <IMG SRC="<dtml-var newname>">
> </dtml-let>
>
> Then in _any_ document within the site I can add the following code;
>
> <dtml-var "buildHeader(
>         root=REQUEST.BASE0,  <-- urlbase of my website(works with site access!)
>         fold=PARENTS[0].id,  <-- id of parent directory
>         path='images',   <-- path to my images folder
>         prefix='hd')">  <-- prefix identifier of image
>
> The correct image is displayed based on the directory location of the
> document. It's not much but it's a start on what we are looking for. I
> still.....   don't understand why I cannot create a Zope reference on the
> fly. It seems strange to me that object references must be hardwired into
> Zope. That I can see,  if you do not already have the object within your
> namespace, it is inaccessible.
>
> Possibly I do not see this correctly, must every object link within a Zope
> website be hardcoded?
>

You can access other objects, just not by name.  You can iterate through all of an
objects parents, looking for objects with a certain meta type.  However, this
doesn't let you get at an object through inheritance, which is what you want.

--sam