[Zope-dev] Returning values for dtml-in

jiva@devware.com jiva@devware.com
Tue, 28 Mar 2000 14:22:21 -0700


Okay, actually, that was a typo, it should have been <dtml-var val>
Does that change anything or no?

On Tue, Mar 28, 2000 at 11:57:44AM -0800, Michel Pelletier wrote:
> 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

-- 
Cinemuck, n.:
	The combination of popcorn, soda, and melted chocolate which
	covers the floors of movie theaters.
		-- Rich Hall, "Sniglets"