[Zope] Fun with Trees

Dieter Maurer dieter@handshake.de
Mon, 3 Jul 2000 22:38:27 +0200 (CEST)


Charlie Wilkinson writes:
 > On Mon, Jul 03, 2000 at 09:35:06AM +0200, Rik Hoekstra waxed eloquent:
 > > 
 > > 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.
 > [...]
 > > [rh]
 > > Try (yes, this is tested):
 > > <dtml-call "REQUEST.set('ret', '')">
 > >  <dtml-in "objectValues()" sort=id>
 > >      <dtml-if "_.has_key('add_to_menu')">
 > >        <dtml-call "ret.append(id)"> 
 > >      </dtml-if>
 > >  </dtml-in>
 > > <dtml-return ret>
 > > 
 > The bigger problem seems to be the namespace issue that Dieter was
 > speaking of.

I found a solution that is much easier than hacking the
TreeDisplay code:

  You do not plan to use REQUEST for information about the
  request but only as a container for a temporary list.
  This can be achieved without REQUEST

	<dtml-with "_.namespace(r=[])">
	  <dtml-in "objectValues()" sort=id>
	    <dtml-if "_.has_key('add_to_menu')">
	       <dtml-call "r.append(_.getitem('sequence-item'))">
	    </dtml-if>
	  </dtml-in>
	  <dtml-return r>
	</dtml-with>



Dieter