473,406 Members | 2,371 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,406 software developers and data experts.

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 5108
(hopefully) any answers?

....

in*******@postmaster.co.uk (phil) wrote in message news:<d7*************************@posting.google.c om>...
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***************@engcorp.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>Hello World<p>\n"
print cgi.FieldStorage()
print "<br>"
b = cgi.FieldStorage()
print b
print "</body></html>"
And the result :
Hello World

FieldStorage(None, None, [MiniFieldStorage('title', 'hello world'),
MiniFieldStorage('excerpt', 'strange')])

FieldStorage(None, 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*******@postmaster.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*@doxdesk.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
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"...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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,...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.