[Zope] ZPT + python script problem

Chris Withers chrisw@nipltd.com
Wed, 14 Aug 2002 10:08:17 +0100


Hi Felix,

Felix Ulrich-Oltean wrote:
> 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.

Yes, in which case, it tries dictionary access using the path segment as a key. 
So it tries to do Time['Hours'], gets a calue and uses that ;-)

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

Not necessary... try it and see :-)

cheers,

Chris