473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

cgi.fieldstorage not getting POST data

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>"
Jul 18 '05 #1
1 4934
as*****@yahoo.com (Al Stoltz) wrote:
#!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.

--
Andrew Clover
mailto:an*@doxdesk.com
http://www.doxdesk.com/
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: python user | last post by:
Hi all, New python experimenter here (that means I don't know what I'm doing). I've installed Python2.3.4 onto an RH8 box, then installed mod_python. While trying to write a small program to...
1
by: Austyn Bontrager | last post by:
Should cgi.FieldStorage examine the environment variable REDIRECT_REQUEST_METHOD before examining REQUEST_METHOD? I'm running Apache, and write my CGI scripts in Python. I have this in a...
1
by: Ames Andreas (MPA/DF) | last post by:
Hi, sorry for following-up to myself. Some remarks: 1) Please excuse the bogus original message. I wrote it a minute before I knocked off work and I promise to never do so again :-) 2)...
1
by: Graeme Matthew | last post by:
Hi all I do a CGI post, I am using CGI.FieldStorage(), I obtain the values etc al works fine. I now need to take the same posted data and resubmit it to a remote server i.e I need to rebuild...
0
by: Neil Benn | last post by:
Hello, I'm writing a simple cgi script and want to be able to access the filename in a FieldStorage file instance. I have successfully manmaged to access the file as a 'file-like object' by...
4
by: Derek Basch | last post by:
Given this FieldStorage object: FieldStorage(None, None, ) I am trying to cgi.urlencode the FieldStorage object to POST to another cgi script. The documentation for urlencode,...
3
by: Chris Curvey | last post by:
I can't be the first person to want to do this, but I also can't seem to find a solution. (Perhaps my Google skills are poor today.) How can I emulate cgi.FieldStorage() for my unit tests so that...
7
by: John Salerno | last post by:
If I want to get all the values that are entered into an HTML form and write them to a file, is there some way to handle them all at the same time, or must FieldStorage be indexed by each specific...
4
by: arorap | last post by:
I've mod_php installed with Apache 2.2. In one of my folders, I'm using the cgihandler as the PythonHandler as my target host runs python only as CGI. Here cgi.FieldStorage() doesn't seem to work....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.