CGI causes me some headaches..

Tim B tim at onegoodidea.com
Thu May 13 12:32:20 EDT 1999


I have a simple HTML form which has a text field,(textfield) a select box
(select)
and a submit command button (Submit).

the submit button causes the following script to be run using the
post method of the form.

#! /usr/bin/python1.5

import cgi

print "Content-type: text/html"
print
print "<TITLE>CGI script output</TITLE>"
print "<H1>This is my first CGI script</H1>"
cgi.test()
form = cgi.FieldStorage
submit = form(0)
print submit

Ignoring all of the "cgi.test" output, the "print submit" line gives rise
to:

FieldStorage(None, None, [])

So I tried using the GET method and got the following:

FieldStorage(None, None, [MiniFieldStorage('Submit', 'Submit'),
MiniFieldStorage('textfield', 'Ritchie Hawtin'), MiniFieldStorage('select',
'techno')])

This is more promising as I can see the values that were originally entered
into the form.
I am wondering how I would go about actually extracting the values ("Ritchie
Hawtin","techno") from the structure.
If I try:

print submit (2)

I get the following error:

Traceback (innermost last): File "/home/httpd/cgi-bin/RP-cgi", line 13, in ?
print submit (2) AttributeError: no __call__ method defined

Please excuse my ignorance but any assistance is greatly appreciated.

Thanks

Tim






More information about the Python-list mailing list