python cgi problem with method = post

P

phil

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
 
P

Peter Hansen

phil said:
(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.

Yet you were hopeful for answers? ;-)

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
 
P

phil

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
 
P

phil

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
 
A

Andrew Clover

phil said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top