473,804 Members | 3,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cgi.fieldstorag e 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.fieldstorag e() 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.FieldStorag e()
id = form.getvalue(' id')

print "Content-Type: text/html"
print
print"<html><bo dy>"
print "<p>value of id is: %s</p>" % id
print "</body></html>"
Jul 18 '05 #1
1 4989
as*****@yahoo.c om (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*@doxd esk.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
1153
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 process form data I discovered that the mod_python.util.FieldStorage class intermixes query and post form data. Since that class looks like a subclass of cgi.py I thought I could start there but it seems to behave the same way. I can't be...
1
1827
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 /techdocs/.htaccess file: ErrorDocument 401 /forms/registration.cgi Require valid-user
1
1639
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) What I really wanted to know was: FieldStorage writes what it reads from the stream that is given to its constructor's fp (or sys.stdin by default) to a temporary file only _in some cases_. My
1
2841
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 the entire raw html request. Does anyone know if you can retrieve the entire request string before parsing it via the cgi module? and then resubmit this to another server?
0
1702
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 using the simple code of : objInFile = objForm.file I can easily read through this data and get all the information out
4
2123
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, http://docs.python.org/lib/module-urllib.html , says that urlencode takes a mapping object or a list of double tuples. I see that I could use cgi.parse_qs and cgi.parse_qsl to create these object types. Should I just use that or should I continue using...
3
2214
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 I don't have to put a web server in the way? what I'd like to do is something like fs = cgi.FieldStorage() fs = "bar" functionToBeTested(fs)
7
1588
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 field name?
4
4885
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. I can see the form data in sys.stdin but cgi.FieldStorage() returns an empty dictionary. Here's the code for the test script I am posting to - -- #!/usr/bin/python
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.