Python CGI post problem

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

    #1

    Python CGI post problem

    I'm having problems with a python cgi script. The script just won't read
    any POST data. Forms with GET data work fine.

    Here's the script:

    #!/usr/bin/python

    import sys
    import os
    import cgi
    import cgitb; cgitb.enable()

    import path
    import site_html
    import session

    session.start()
    form=cgi.FieldS torage(keep_bla nk_values=True)

    ....

    site_html.heade r()

    print form.keys()
    ....


    The for is as follows:
    <form action"=main" method="post">
    <input type="hidden" name="a" value="b">
    <input type="submit">
    </form>

    I always just get [] from the print form.keys(). Chaning method="post"
    to method="get" works fine.

    <VirtualHost 217.160.141.74>
    Serveradmin eddy@fericom.ne t
    ServerName guinies.fericom .net
    DocumentRoot /var/www/eddy/guinies/cgi
    <Directory /var/www/eddy/guinies/cgi/>
    SetEnv MAIN_DIR /var/www/eddy/guinies
    Options ExecCgi
    Order allow,deny
    Allow from all
    SetHandler cgi-script
    DirectoryIndex main
    </Directory>
    Alias /images/ /var/www/eddy/guinies/images/
    <Directory /var/www/eddy/guinies/images>
    Options None
    </Directory>
    </VirtualHost>

    I am stuck with this. On another machine where I use ScriptAlias and
    python CGI scripts the post form stuff works fine. Any ideas?

    Thanks


    Eddy

  • Paul Boddie

    #2
    Re: Python CGI post problem

    Eddy Ilg wrote:[color=blue]
    > I'm having problems with a python cgi script. The script just won't read
    > any POST data. Forms with GET data work fine.[/color]

    [...]
    [color=blue]
    > form=cgi.FieldS torage(keep_bla nk_values=True)[/color]

    Since FieldStorage uses various defaults when you don't specify the fp
    and environ parameters, it may be worth checking those defaults
    (particularly what os.environ contains) to see if the FieldStorage
    object gets incorrectly initialised. What you should be seeing in
    os.environ is a value for "REQUEST_METHOD " of "POST" (or possibly
    "post") - if not, FieldStorage will attempt to read the fields from the
    QUERY_STRING environment variable, producing the results you've
    observed.

    Paul

    Comment

    Working...