Python CGI post problem

E

Eddy Ilg

I'm having problems with a python cgi script. The script just won't read
any POST data. Forms with GET data work fine.

Here's the script:

#!/usr/bin/python

import sys
import os
import cgi
import cgitb; cgitb.enable()

import path
import site_html
import session

session.start()
form=cgi.FieldStorage(keep_blank_values=True)

....

site_html.header()

print form.keys()
....


The for is as follows:
<form action"=main" method="post">
<input type="hidden" name="a" value="b">
<input type="submit">
</form>

I always just get [] from the print form.keys(). Chaning method="post"
to method="get" works fine.

<VirtualHost 217.160.141.74>
Serveradmin (e-mail address removed)
ServerName guinies.fericom.net
DocumentRoot /var/www/eddy/guinies/cgi
<Directory /var/www/eddy/guinies/cgi/>
SetEnv MAIN_DIR /var/www/eddy/guinies
Options ExecCgi
Order allow,deny
Allow from all
SetHandler cgi-script
DirectoryIndex main
</Directory>
Alias /images/ /var/www/eddy/guinies/images/
<Directory /var/www/eddy/guinies/images>
Options None
</Directory>
</VirtualHost>

I am stuck with this. On another machine where I use ScriptAlias and
python CGI scripts the post form stuff works fine. Any ideas?

Thanks


Eddy
 
P

Paul Boddie

Eddy said:
I'm having problems with a python cgi script. The script just won't read
any POST data. Forms with GET data work fine.
[...]

form=cgi.FieldStorage(keep_blank_values=True)

Since FieldStorage uses various defaults when you don't specify the fp
and environ parameters, it may be worth checking those defaults
(particularly what os.environ contains) to see if the FieldStorage
object gets incorrectly initialised. What you should be seeing in
os.environ is a value for "REQUEST_METHOD" of "POST" (or possibly
"post") - if not, FieldStorage will attempt to read the fields from the
QUERY_STRING environment variable, producing the results you've
observed.

Paul
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top