python cgi problem with method = post

Discussion in 'Python' started by phil, Sep 19, 2003.

  1. phil

    phil Guest

    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
    phil, Sep 19, 2003
    #1
    1. Advertising

  2. phil

    phil Guest

    (hopefully) any answers?

    ....

    (phil) wrote in message news:<>...
    > 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
    phil, Sep 21, 2003
    #2
    1. Advertising

  3. phil

    Peter Hansen Guest

    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
    Peter Hansen, Sep 21, 2003
    #3
  4. phil

    phil Guest

    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 <> wrote in message news:<>...
    >
    > 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
    phil, Sep 22, 2003
    #4
  5. phil

    phil Guest

    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
    phil, Oct 5, 2003
    #5
  6. phil <> 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:
    http://www.doxdesk.com/
    Andrew Clover, Oct 5, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vishal
    Replies:
    1
    Views:
    661
    Steve C. Orr [MVP, MCSD]
    Dec 21, 2004
  2. Michael Foord

    POST method, CGI and file transfer

    Michael Foord, Sep 4, 2004, in forum: Python
    Replies:
    0
    Views:
    370
    Michael Foord
    Sep 4, 2004
  3. Robert Brewer

    RE: POST method, CGI and file transfer

    Robert Brewer, Sep 4, 2004, in forum: Python
    Replies:
    1
    Views:
    345
    Michael Foord
    Sep 6, 2004
  4. Eddy Ilg

    Python CGI post problem

    Eddy Ilg, Nov 23, 2005, in forum: Python
    Replies:
    1
    Views:
    674
    Paul Boddie
    Nov 24, 2005
  5. Don Glover the younger

    ASP, FORMS, POST METHOD And Post with out form(???)

    Don Glover the younger, Jul 13, 2003, in forum: ASP General
    Replies:
    0
    Views:
    449
    Don Glover the younger
    Jul 13, 2003
Loading...

Share This Page