[mod_python] Trouble fetching POST arguments

Graham Dumpleton grahamd at dscpl.com.au
Wed Mar 16 20:48:32 EST 2005

Point whatever form you are using at:



<form action="http://dscpl.user.openhosting.com/~grahamd/testing/details.py" method="post">
        <input type="text" name="handle" maxlength="32"/>

        <input type="password" name="password" maxlength="32"/>
        <input type="submit" name="login" value="Log in!"/>

That URL will display various details about the request and for me at
least for a post form, yields something for req.read(). As an example,


You can see my code for generating this at:


I'll leave this up for a while, but will take it down at some point.

Hope this helps.


Davin Boling wrote ..
> (First of all, a big thanks to Graham for putting up with a thinly 
> veiled attempt of escapism from Too Many Mailing Lists syndrome. :) That
> said, no offense to him, the e-mail he forwarded really wasn't mailing
> list material: I just wanted a quick second opinion to make sure I was
> sane.)
> I was working with my own custom handler when I ran into a random 
> roadblock: for some reason the headers of submitted forms were being 
> eaten, and I'm not using mod_python.publisher! With req.read() returning
> blank strings, it was obvious that util.FieldStorage(req) wasn't going
> to be of much use. I also tried a simple test, which offered some very
> bizarre results. I changed the top of my handler to the following:
> def handler(req):
>      test = req.read()
>      req.log_error(test)
> And this is what I get whenever I try to POST to it:
> [Wed Mar 16 19:27:53 2005] [error] [client X.X.X.X] GET, referer: 
> http://real.url/nothere
> Very interesting, GET instead of POST. Maybe my HTML was at fault? I 
> wrote up a small test form that was *nothing* but a good form: same result.
> At my wit's end, I wrote a quick handler from scratch and placed it into
> the same environment. I didn't restart Apache, all I did was make a copy
> of __init.py__ and overwrite it with a simple test. Interestingly 
> enough, the "handler from scratch" worked as expected: req.read() 
> returned a non-empty string, and req.method returned "POST".
> I overwrote __init.py__ again with the original version, and reran the
> same form. ...Back to GET again. It makes no sense! It's like something
> upstream is "eating" req.read(), but how is that possible when I'm 
> fetching the contents of req.read *at the start* of my handler(req) 
> function?
> Here's my Apache configuration for the virtual host in question, if it
> helps:
> <VirtualHost>
> ServerName foo.bar.baz
> DocumentRoot /not/a/real/path
>    <Directory /not/a/real/path>
>     PythonDebug On
>     SetHandler mod_python
>     PythonHandler handler
>     <IfModule mod_access.c>
>       Order allow,deny
>       Allow from all
>     </IfModule>
>    </Directory>
> </VirtualHost>
> (I'd share the code in question, but it's going to be placed in a secure
> environment and I can't have it archived to the mailing list. I'll 
> report my results when I find the culprit, but in the meantime I'd 
> appreciate feedback on what people think might be going wrong.)
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list