By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,784 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,784 IT Pros & Developers. It's quick & easy.

python cgi problem with method = post

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
(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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.