[Zope] Running up and down the hierarchy

Danny William Adair Danny@Adair.net
Fri, 9 Mar 2001 11:27:50 +1300


Hello to everybody!

Supposed I have an object hierarchy looking like this:

the_root------A-----Aa
                 ---Ab(image)
        ------B-----Ba
                 ---Bb------Bba
                         ---Bbb(DTML document)

A DTML document "Bbb" lying in folder Bb wants to access the image in Folder
Ab.
The only way I know how to do this is

<dtml-with Bb>
  <dtml-with B>
    <dtml-with the_root>
      <dtml-with A>
        <dtml-var Ab>     (or do whatever with it)
      </dtml-with>
    </dtml-with>
  </dtml-with>
</dtml-with>

Of course this sucks.
The first thing I thought when I encountered this situation was "I might
have to think over my folder structure". I did, but still have this
situation in some situations, and for several reasons I want to leave some
of my objects as indicated in the figure above(won't change it). Nesting a
couple of with's does work, but I would rather like to do something like
this:

<dtml-with "Bb/B/the_root/A">     (or dtml-path_with...)
  <dtml-var Ab>
</dtml-with>

or maybe even

<dtml-var "Bb/B/the_root/A/Ab">     (dtml-path_var... resp.)

Is there something like this around? I took a look at the PathHandler
product, but I don't have enough Zen (yet) for doing some __bobo_traverse__
magic myself (that's the entry point, right?). I guess a self-defined dtml
tag that does the with-nesting (running the ladders) would do fine. How am I
going to do this? Or are there other ways? I just want to make the dtml more
readable (and shorter).

Thanks so much in advance,
Danny

btw: Am I the only one in need for something like this?