cgi.fieldstorage not getting POST data

A

Al Stoltz

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

Andrew Clover

#!d:/python/python.exe

I don't know if this is related to your problem (I haven't tried 2.3 or
ActiveState's kit for CGI on Windows), but what you probably want is:

#!d:/python/python.exe -u

To ensure that newline characters are not fiddled with. This will certainly
be necessary if you are dealing with file upload POST requests; see if it
also fixes the problem with plain url-encoded POSTs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top