[Zope] quick python book - question about the feedback form example

Jason Cunliffe jasonic@nomadicsltd.com
Sat, 9 Dec 2000 13:03:18 -0500


Lee

I'm no expert, but I thought all Python Scripts [Methods] in Zope need to
include 'self' as the first argument.

Thus you should try instead

"""feedback.py: A simple feedback form application"""
def save_feedback(self, feedback_type, comments):
    etc..

among others do check out the ZDP  FAQ at
http://zdp.zope.org/projects/zfaq/faq/ExternalMethods#952541309

and also the new Zope Book Chapter 8
http://www.zope.org/Members/michel/ZB/ScriptingZope.html
[See section about External Python halfway down, but beware the new change
in terminology from 'Python Methods' to 'Python Scripts' - slightly out of
sync with the Quick Python Book]

good luck
- Jason
___________________________________________________________
Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']


----- Original Message -----
From: Lee <lee.reilly@ntlworld.com>

> - I then create a python method called 'feedback.py' containing the
> following:
>
> feedback.py
> --------------
> """feedback.py: A simple feedback form application"""
> def save_feedback(feedback_type, comments):
>     """ A function to handle submitted feedback form data"""
>     # Open a file for appending to save the feedback
>     # creating the file if necessary
>     try: file=open("feedback_data", "a")
>     except IOError:
>         file=open("feedback_data", "w")
>     # Save the data
>     file.write("Feedback type: %s\n" % feedback_type)
>     file.write("Comments: %s\n\n % comments)
>     file.close()
>     return "Thankyou for your feedback!"