[ZPT] Getting TAL to use multiple return info

Tino Wildenhain tino at wildenhain.de
Mon Apr 10 01:40:48 EDT 2006


Robert Sirois wrote:
> Hey, how do I get multiple variables from a script to use on a ZPT?
> 
> ie. Script:
> 
> a = 'yo'
> 
> b = ' wuzzup'
> 
> c = []
> 
> c.append(a)
> 
> c.append(b)
> 
> return c
> 
> I can get a list to print out on the page, but how could I use each one
> separately?

Well, let me point out in fact you return only one variable :-)
(And btw, you can construct lists much easier - no need for
a, b and append() :-)

To have easy access to a lot of names throughout your ZPT,
the usual pattern is to call your ZPT from controller
python script.

Like this:

a='yo'
b='wuzzup'

return context.yourZPT(a=a,b=b)

and in your ZPT you access the values simply by:

options/a  and options/b

this can be extended by using arbitrary nested dictionaries
(and lists for loops)

a=dict(name='peter',age=25)

return context.yourZPT(a=a)  # left hand 'a' is the name you use
                             # inside ZPT of course

and inside ZPT: options/a/name   options/a/age

Regards
Tino Wildenhain


More information about the ZPT mailing list