473,795 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python cgi problem with method = post

This is a quick plea on something that has me stumped.

I have a python script importing "cgi"

I developed my script on a local machine using method = get for
uploading form data.

My code worked locally and on the hosting service I'm using.

I changed to using method = post

On my local machine this change works transparently.

On my hosting service's machine, all the values that the form returns
to the script are now empty.

So, I don't expect anyone to be able to answer this ... but what
*kind* of thing should I be looking for? Is it to do with versions of
python (2.1.3 locally, 2.2 remotely) or "cgi"? Or the webserver (I'm
using Apache on Debian locally, I suspect my host is Apache on Red Hat
7.1)

Is it something I haven't thought of?

cheers

phil jones
Jul 18 '05 #1
5 5122
(hopefully) any answers?

....

in*******@postm aster.co.uk (phil) wrote in message news:<d7******* *************** ***@posting.goo gle.com>...
This is a quick plea on something that has me stumped.

I have a python script importing "cgi"

I developed my script on a local machine using method = get for
uploading form data.

My code worked locally and on the hosting service I'm using.

I changed to using method = post

On my local machine this change works transparently.

On my hosting service's machine, all the values that the form returns
to the script are now empty.

So, I don't expect anyone to be able to answer this ... but what
*kind* of thing should I be looking for? Is it to do with versions of
python (2.1.3 locally, 2.2 remotely) or "cgi"? Or the webserver (I'm
using Apache on Debian locally, I suspect my host is Apache on Red Hat
7.1)

Is it something I haven't thought of?

cheers

phil jones

Jul 18 '05 #2
phil wrote:

(hopefully) any answers?


The mailing list and newsgroup are working well enough, so if you
receive no useful answers it's likely because nobody could understand
the question clearly enough to think how to answer.

One thing you might consider is including some actual samples of
code, so people don't have to imagine which of the five dozen
possible approaches you are actually using.

Also make sure you have tried other approaches to ensure that the
problem is actually with your own code and not with some host-specific
problem which nobody else will ever be able to reproduce locally.
So, I don't expect anyone to be able to answer this ... but what
Yet you were hopeful for answers? ;-)
*kind* of thing should I be looking for? Is it to do with versions of
python (2.1.3 locally, 2.2 remotely) or "cgi"? Or the webserver (I'm
using Apache on Debian locally, I suspect my host is Apache on Red Hat
7.1)


Python includes excellent facilities for debugging problems of various
kinds, including this kind. Why not experiment a little and see what you
can come up with? It's unclear from your description where your problem
might be so without additional information any suggestions are random
shots-in-the-dark, and that I suspect is why no one responded yet.

Also, I just noticed, you waited only one day before your second post.
That's far too little time to wait, as for many people it can take
several days for Usenet posts to reach them and, furthermore, you posted
at the end of the work week and many people read Usenet only at work.

Summary: experiment, post more and more detailed information, and be
more patient.

-Peter
Jul 18 '05 #3
Sorry, my bad!

I've been using other forums where there's turnaround of a couple of
hours or things get lost in the depths of history. Forgot what Usenet
is like :-)

I'll go away and look at the problem some more and try to come back
with more details.

cheers

phil jones

Peter Hansen <pe***@engcorp. com> wrote in message news:<3F******* ********@engcor p.com>...

The mailing list and newsgroup are working well enough, so if you
receive no useful answers it's likely because nobody could understand
the question clearly enough to think how to answer.

One thing you might consider is including some actual samples of
code, so people don't have to imagine which of the five dozen
possible approaches you are actually using.

Also make sure you have tried other approaches to ensure that the
problem is actually with your own code and not with some host-specific
problem which nobody else will ever be able to reproduce locally.
So, I don't expect anyone to be able to answer this ... but what
Yet you were hopeful for answers? ;-)
*kind* of thing should I be looking for? Is it to do with versions of
python (2.1.3 locally, 2.2 remotely) or "cgi"? Or the webserver (I'm
using Apache on Debian locally, I suspect my host is Apache on Red Hat
7.1)


Python includes excellent facilities for debugging problems of various
kinds, including this kind. Why not experiment a little and see what you
can come up with? It's unclear from your description where your problem
might be so without additional information any suggestions are random
shots-in-the-dark, and that I suspect is why no one responded yet.

Also, I just noticed, you waited only one day before your second post.
That's far too little time to wait, as for many people it can take
several days for Usenet posts to reach them and, furthermore, you posted
at the end of the work week and many people read Usenet only at work.

Summary: experiment, post more and more detailed information, and be
more patient.

-Peter

Jul 18 '05 #4
I'm still struggling with the mysterious problem of FieldStorage and
method = Post.

However, I've noticed something which might solve my problem but is
very strange. My CGI script :

#! /usr/bin/python

import cgi

print """Content-type: %s

""" % 'text/html'

print "<html><body>He llo World<p>\n"
print cgi.FieldStorag e()
print "<br>"
b = cgi.FieldStorag e()
print b
print "</body></html>"
And the result :
Hello World

FieldStorage(No ne, None, [MiniFieldStorag e('title', 'hello world'),
MiniFieldStorag e('excerpt', 'strange')])

FieldStorage(No ne, None, [])

So I take it that the first call to FieldStorage wipes out the data
for any subsequent calls? Is this right? Don't see it documented
anywhere?

If I have worked out the puzzle, do I now win my secret Python Decoder
Ring?

phil jones
Jul 18 '05 #5
phil <in*******@post master.co.uk> wrote:
So I take it that the first call to FieldStorage wipes out the data
for any subsequent calls? Is this right?


This is the case with CGI in general, not specifically a Python thing. A
POSTed form submission is sent in the body of the HTTP request, which is
the 'standard input' stream for the script. You can only read the contents
of a stream once. With the cgi module, this reading occurs when
FieldStorage is constructed, so trying to make more than one FieldStorage
is generally a mistake.

I don't know why this might have worked locally - it shouldn't!

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

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

Similar topics

14
2868
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon" in the subject of any post to this newsgroup. Please ignore the old thread. I've also updated my webpage http://ece.arizona.edu/~edatools/Python Anyone with some good ideas for "Python 3" is welcome to contribute. I hope GvR won't sue me for...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10000
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...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.