python cgi problem with method = post

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • phil

    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
  • phil

    #2
    Re: python cgi problem with method = post

    (hopefully) any answers?

    ....

    interstar@postm aster.co.uk (phil) wrote in message news:<d7825a3e. 0309191202.dc02 042@posting.goo gle.com>...[color=blue]
    > 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[/color]

    Comment

    • Peter Hansen

      #3
      Re: python cgi problem with method = post

      phil wrote:[color=blue]
      >
      > (hopefully) any answers?[/color]

      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.
      [color=blue][color=green]
      > > So, I don't expect anyone to be able to answer this ... but what[/color][/color]

      Yet you were hopeful for answers? ;-)
      [color=blue][color=green]
      > > *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)[/color][/color]

      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

      Comment

      • phil

        #4
        Re: python cgi problem with method = post

        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 <peter@engcorp. com> wrote in message news:<3F6DC6D3. E6454738@engcor p.com>...[color=blue]
        >
        > 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.
        >[color=green][color=darkred]
        > > > So, I don't expect anyone to be able to answer this ... but what[/color][/color]
        >
        > Yet you were hopeful for answers? ;-)
        >[color=green][color=darkred]
        > > > *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)[/color][/color]
        >
        > 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[/color]

        Comment

        • phil

          #5
          Re: python cgi problem with method = post

          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

          Comment

          • Andrew Clover

            #6
            Re: python cgi problem with method = post

            phil <interstar@post master.co.uk> wrote:
            [color=blue]
            > So I take it that the first call to FieldStorage wipes out the data
            > for any subsequent calls? Is this right?[/color]

            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:and@doxd esk.com

            Comment

            Working...