[Zope-dev] Returning values for dtml-in

Michel Pelletier michel@digicool.com
Tue, 28 Mar 2000 11:57:44 -0800


jiva@devware.com wrote:
> 
> What kind of result do I need to return from a python method in order
> for the return value to be usable by <dtml-in> ?

A sequence.
 
> In other words, I want to do:
> 
> def blah(self):
>     l = [{val : 'blah1'}]
>     return l
> 
> then in my dtml code do:
> 
> <dtml-in blah>
> <dtml-var val1>
> </dtml-in>
> 
> Am I missing something?

You are iterating over a list that contains one item.  The in block will
be execute once at which time the dictionary which is the only item in
the list will be pushed on the DTML namespace stack.  You then ask for
the name 'val1', which does not exist in any namespace, even the
namespace of the dictionary.  It is a *key* in the dictionary, but it is
not a name of the dictionary.

<dtml-in blah>
  <dtml-var "_['sequence-item'][val1]">
</dtml-in>

Well use the val1 key to get the value 'blah1' out of the dictionary
(which is sequence-item).

-Michel