[Zope] return structured result from Python scripts for page templates

Thomas B. Passin tpassin@mitretek.org
Thu, 25 Jul 2002 10:33:50 -0400


[Nagypal Gabor]

> Anyway, I do not insist on creating objects. I just would like to have a 
> way to return a structured result from a Python script, where I can 
> access the named attributes easily. 

Example 1:

Script named "script_test":

return [1,2]

Typical usage in DTML document:

<dtml-var "script_test()[1]">
 =====================
Example 2:

Script:

return {"a":1,"b":2}

Typical usage in DTML:

<dtml-var "script_test()['a']">
========================
Example 3;

Script:

p={"a":1,"b":2}
return p

Same usage as Example 2.


Should work in ZPT too.

Cheers,

Tom P