[Zope] building a revisitable object list???

Darran Edmundson dee124@rsphy1.anu.edu.au
Mon, 14 Feb 2000 01:40:52 +1100 (EST)


Pardon the subject title - it was either that or the
alternative "lost in DTML land" ...

I'm using nested <dtml-in> blocks to descend two levels
into a portion of my ZODB.  I'm only interested in the
leaf nodes.  However, rather than act on them while
"visiting", I want to conditionally store a reference to them
in a python list so that I can visit any leaf later on.  
I'll make it clear with a pared-down example.

root
  folder1
    subfolder1a
    subfolder1b
  folder2
    subfolder2a

I want to build a list such that I can visit various
subfolders without having to search them out.  

Q1) If I want to be able to visit subfolder1a and subfolder2a
from the root, do I need to store the entire path or
will some sort of internal ZODB id suffice?

Q2) Assuming I need the entire path, I've toyed around with
creating a list
  mylist = [(folder1,subfolder1a),(folder2,subfolder2a)]
for which I could presumably then visit the subfolders via
  <dtml-in mylist><dtml-with "_[sequence-item][0]">
  <dtml-with "_[sequence-item][1]"> .... </dtml-with>
  </dtml-with></dtml-in>

I'm having trouble creating this list, my attempt being
the root-level DTML snippet:

<dtml-in "objectValues(['Folder'])">
   <dtml-let level1id=id>
   <dtml-in "objectValues(['Folder'])">
       <dtml-let curloc="(level1id,id)">
       <dtml-call "mylist.append(curloc)"> (conditionally called)
       </dtml-let>
   </dtml-in>
   </dtml-let>
</dtml-in>

In my actual problem, I'm building up multiple lists during
this single pass of the tree.  These lists can then be
used later on by other DTML methods.

I would very much appreciate feedback on the above.

Cheers,
Darran.