[Zope] A DTML problem using Namespaces

Dieter Maurer dieter@handshake.de
Sun, 8 Oct 2000 16:07:52 +0200 (CEST)


tav writes:
 > ....  i have a dtml method called "parseit", and i have
 > three dtml documents, called "tav", "noa" and "Bill".
 > .... 
 > however i get stuck when in parseit, as i dont know how to do <dtml-var
 > Bill>, i tried to set Bill in the namespace by using <dtml-with
 > Bill><dtml-var parseit>, and then tried to call <dtml-var id> within
 > "parseit" but that doesn't work :/
It does not work, because <dtml-with Bill> renders "Bill" (leading to
a string which does not have an attribute "id").
It will work, when you use:

	<dtml-with "Bill">...</dtml-with>

Note the "...". They prevent automatic rendering.

 > and, again, i want this to be done automatically, so i dont want to have to
 > manually list Bill, tav, noa, etc....
This is an FAQ. You want computed variable access. You use
"_.getitem(...)" (if you want the object itself) or "_[...]"
(if you want a rendered result) for this.

Thus, if you want to process all owners, you could do:

	<dtml-in owners>
	  <dtml-let owner=sequence-item>
	    <dtml-with "_.getitem(owner)">
	      <dtml-var parseit>
	    </dtml-with>
	  </dtml-let>
	</dtml-in>



Dieter