Hi all 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. Here is last part of the error message. ---------------------------------------------------------- 'root': <Application instance at 8d91c78>, 'template': <ZopePageTemplate instance at 8f44068>, 'traverse_subpath': [], 'user': 1381}) File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 158, in __call__ File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 191, in interpret File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 523, in do_useMacro File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 191, in interpret File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 542, in do_defineSlot File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 191, in interpret File /home1/sepg/Site/lib/python/TAL/TALInterpreter.py, line 402, in do_setLocal_tal File /home1/sepg/Site/lib/python/Products/PageTemplates/TALES.py, line 247, in evaluate File /home1/sepg/Site/lib/python/Products/PageTemplates/Expressions.py, line 189, in __call__ File /home1/sepg/Site/lib/python/Products/PageTemplates/Expressions.py, line 179, in _eval Undefined: Sorry, an error occurred
At 12:02 AM 8/14/2002 +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. Here is last part of the error message.
Where in the Zope Book does this come from? Do you have a Python script called GetProjectsPython in the same folder as your page template? David --- David Elfstrom, P.Eng elfstrom@sten.sunnybrook.utoronto.ca Systems Engineer, Research Computing Sunnybrook & Women's College Health Sciences Centre Rm#S6-20, 2075 Bayview Avenue, Toronto, Canada M4N 3M5 phone: 416-480-6100 x3416 fax: 416-480-5714 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002
David Elfstrom wrote:
Where in the Zope Book does this come from?
http://www.zope.org/Documentation/Books/ZopeBook/current/AdvZPTold.stx I got this thing working. I had added a paramter to the "Parameter List" for the python script in question (for testing). Talk of oversight !!!!! The problem lay there. The moment I removed this fellow everything fell in place. Thanks Chetan
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.
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
participants (4)
-
Chetan Kumar -
Chris Withers -
David Elfstrom -
Felix Ulrich-Oltean