[Zope] ZPT + python script problem

Felix Ulrich-Oltean felixvulrich@yahoo.co.uk
Tue, 13 Aug 2002 19:51:06 +0100


I'm not sure I understand you correctly, but if your script returns a
dictionary like this:

{'Hours' : value, 'Mins' : othervalue}

then you could do something like:

<span tal:define="Times here/GetProjectsPython;
                  Hours python:Times['Hours'];
                  Mins  python:Times['Mins']"
     tal:replace="string:${Hours} is ${Mins}">
</span> Time in hours and minutes

I think that when you say "string:${Times/Hours}", zope will look for
either:

a) a method called Hours on the object Times, just like "here/object/absolute_url" calls the absolute_url() method on "object"

or

b) a contained item, like in a folder, e.g. "here/myImage"

but it finds neither.

In any case, using the python: prefix in your expressions might help
you out.

Hope that makes sense,

Felix.

On Wed, Aug 14, 2002 at 12:02:21AM +0530, Chetan Kumar wrote:
> This fellow (copied straight from Zope Book) does not work !!!!!
> 
> ------------------------------------------------------
> <span tal:define="Times here/GetProjectsPython"
>      tal:replace="string:${Times/Hours} is ${Times/Mins}">
> </span> Time in hours and minutes
> ------------------------------------------------------
> 
> The python script GetProjectsPython returns a dictionary with
> Hours and Mins as keys and their values.