cgi.fieldstorage not getting POST data

Al Stoltz astoltz at yahoo.com
Thu Jan 22 19:04:39 CET 2004


Greetings all.  

I've got a small web application (just a web interface to a MS-access
database) and I recently upgraded ActiveState's python dist. from 2.2
to their latest (2.3.2 I think). In the process, I broke some of my
cgi scripts.  A little troubleshooting reveals that the
cgi.fieldstorage() method is not receiving any data at all when using
an HTTP POST request in my HTML.  If I change to a GET request, all is
well.

I'll add that the scripts were working fine with the POST request
under version 2.2.  A quick glance through the change log at both
ActiveState and Python.org didn't yield any clues that the cgi module
might have changed from 2.2 to 2.3

OS is windows2000 and I'm using ActiveState's version because I need
the ODBC module that it comes with it.

Code snippets are below.  If I change method="post" to method="get",
the value of id get passed into test1.py like you would expect.
Otherwise the value that form.getvalue('id') returns is 'none'.

Anyone have any insight?  Thanks for looking.

--------------- HTML Page---------------
<body>
<p>This is a test.</p>
<form action="http://my_server.com/cgi-bin/test1.py" method="post">
<input type="text" name="id" value="" size='16' />
<input type="submit" value="Test" />
</form>

</body>

--------------- test1.py -----------------------------

#!d:/python/python.exe

import cgi
import cgitb
cgitb.enable()

form = cgi.FieldStorage()
id = form.getvalue('id')

print "Content-Type: text/html"
print
print"<html><body>"
print "<p>value of id is: %s</p>" % id
print "</body></html>"



More information about the Python-list mailing list