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

Lee lee.reilly@ntlworld.com
Sat, 09 Dec 2000 17:16:46 +0000


Hi,

Finally got my hands on The Quick Python book and have read the first 13
chapters. I've now jumped to chapter 26, "Using Zope", to try out some
of the examples there. I'm havng a problem with the feedback form
example (p326) and I'd be really grateful if someone could point out
what I am doing wrong.

- I created a directory in the root called 'feedback' and to this I
added a DTML document, 'index_html'. I see no probs with this but maybe
someone could confirm that the post action is correct for me.

index_html
-------------
<dtml-var standard_html_header>
<FORM ACTION="/cgi-bin/feedback/save_feedback" METHOD="POST">
Type of feedback:
<SELECT NAME="feedback_type">
    <OPTION>Compliment
    <OPTION>Criticism
</SELECT>
<p>
Your comments:
<TEXTAREA NAME="comments"></TEXTAREA>
<INPUT TYPE="SUBMIT" VALUE="Submit Feedback">
</FORM>
<dtml-var standard_html_footer>

- 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!"

^ On the Python method addition screen I use feedback(.py) as the ID +
title and insert "feedback_type, comments" in the parameter list. Of
course, this results in an error SyntaxError & Invalid token.

I tried to modify it by taking out the first 2 lines of the above code,
renaming the method 'save_feedback' but still no success. I'm unsure
whether the return statement will do anything in Zope also.

Can anyone help?

- Best regards,

Lee (with 10 crossed fingers & toes)

--
Lee Reilly
mailto:lee.reilly@ntlworld.com
http://www.footkick.co.uk/lee