[Zope] Two newbie questions

Evan Simpson evan@4-am.com
Mon, 06 Sep 1999 21:21:27 -0500


Chris Fassnacht wrote:

> If I have a folder structure like this:
>
>           A
>        /      \
>      B        C
>     / \       /  \
>   D   E   F    G
>
> Then I can reference an object in A, B, or D from A, B, or D using <dtml-var
> objectid>.  But if I try to reference something in G from B, for instance, I
> get a Zope error.

First, understand that what is accessible to a given object does not depend
(solely) on its place in the containment hierarchy.  What is *does* depend on
is the path used to reach the object.  If you access B via 'A/B', then B's
context contains only itself and A, so you'd need to do something like
<dtml-with C><dtml-var G></dtml-with>.  On the other hand, if you accessed B
via 'A/C/B', then C is already part of B's context, and you can access G
directly with <dtml-var G>.   If you're wondering how 'A/C/B' could be a valid
URL, realize that from 'A/C' you can proceed to any object in C *or A*.  Thus,
a valid (if weird) path is 'A/C/B/C/A/C/C/B/E'.


> What I'm trying to do is to maintain a list of object ids in an object's
> lines property and then generate links (<a href=>'s) from the list.  So, I
> could also use some direction in using the referenced object id in the lines
> property to access its properties (title, mostly).

Since a lines-type property is a sequence of strings, you could do something
like:

<dtml-in "myobject.the_lines"><a href="&dtml-sequence-item;"><dtml-var
"_[_['sequence-item']].title"></a></dtml-in>

This assumes that every object id in the_lines is in the current context.