[Zope] Fun with Trees

Dieter Maurer dieter@handshake.de
Mon, 3 Jul 2000 00:15:03 +0200 (CEST)


Charlie Wilkinson writes:
 > I'm trying to use dtml-tree to create a selective menu of objects based
 > on whether or not the object has an "add_to_menu" property.  I've pretty
 > much figured out that I need a wrapper around objectValues that will
 > filter out the objects that don't have the "add_to_menu" property.
 > This wrapper would be called with dtml-tree's "branches" attribute.
 > I'm trying to do this wrapper in a DTML method and I've gotten all the
 > way to where I have to return a list of "actual objects", so says the
 > DTML Quick Reference.
 > 
 > Is there someone who could 'splain to me how to build a list of objects
 > in DTMLese?
 > 
 > Here's what I have so far (obviously not working):
 > 
 > <dtml-call "REQUEST.set('ret', '')">
 > <dtml-in "objectValues()" sort=id>
 >     <dtml-if "_.has_key('add_to_menu')">
 >       <dtml-call "REQUEST.set('ret', ret + ' ' + _['sequence-item'])">
 >     </dtml-if>
 > </dtml-in>
 > <dtml-return "_.string.split(ret)">
That's perfect.

Almost surely, your problem results from the fact
that "dtml-tree" does not expect "branches" to be
a DTML method and does not pass a namespace to it.

I do not know, how you can avoid this (other than
changing the "dtml-tree" code.



Dieter