Two newbie questions
Hi, I'm new to Zope but have some programming experience and elementary web-design skills. I've been looking through the list archives, but haven't found the answers to a couple of questions. Hope someone can help. 1. Object reference across hierarchies. 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. I'm not fully up to speed on the idea of namespaces, but I get the feeling that this is the source of my problems. Unfortunately, I'm not sure how force a reference to something in a different namespace using only its object id (that is, without having to reproduce the full url path). Could someone enlighten me? 2. Looping a lines property I've been trying to use the <dtml-in> loop structure to go through the entry in an custom ZClass object's lines property. But I'm not sure of the syntax (I've looked through most of the documentation and can't find more than a minimal description on pg. 44 of the Zope Conten Manager's Guide), and what I've tried so far isn't working. I can access individual line items using <dtml-var "objectid.linesid[n]">, but was hoping to avoid having to create an increment variable for n, test, increment, etc., since the <dtml-in> structure looked so slick. 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). Thanks very much for any assistance. Chris Fassnacht
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.
participants (2)
-
Chris Fassnacht -
Evan Simpson