what is wrong with this code
####python code: example def hello(name="dad",age=29): return "Hello %s you are %d years old" % (name ,age) ###Page template testexample <html> <boddy> <h2> <span tal:replace="python:here.example.hello(name='daughter',age=6)"></span> </h2> </body> </html> when I test testexample i got something like Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: hello I was expecting, hello daughter your age is 6 How can I fx this problem? thanks
On Fri, 2003-10-03 at 13:20, Jianping Zhu wrote:
####python code: example def hello(name="dad",age=29):
return "Hello %s you are %d years old" % (name ,age)
If you're putting this into Python Script object, try adding name and age to the list of parameters and just use the following for the contents: return 'Hello %s you are %d years old' % (name, age) A Python Script object is the Zope analog to what you would create with a def statement in regular Python. HTH, Dylan
PythonScript are *never* defined with "def ...". Check the ZopeBook for examples. -aj --On Freitag, 3. Oktober 2003 16:20 Uhr -0400 Jianping Zhu <jzhu@fisher.forestry.uga.edu> wrote:
#### python code: example def hello(name="dad",age=29):
return "Hello %s you are %d years old" % (name ,age)
### Page template testexample <html> <boddy>
<h2> <span tal:replace="python:here.example.hello(name='daughter',age=6)"></span> </h2> </body> </html>
when I test testexample i got something like
Zope Error Zope has encountered an error while publishing this resource.
Error Type: AttributeError Error Value: hello
I was expecting, hello daughter your age is 6 How can I fx this problem? thanks
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Andreas Jung -
Dylan Reinhardt -
Jianping Zhu