[mod_python] Trouble fetching POST arguments

Davin Boling davin at wordpainter.net
Wed Mar 16 19:49:10 EST 2005


(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 69.15.43.130:80>
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.)



More information about the Mod_python mailing list