Jesus Loves GRASS

Technical blog about GRASS/GIS,open source geoinformatics and MAPSERVER.

Friday, October 05, 2007

By the Love of G-d where are my POST variables !!!!

I am working in a WPS web service, using mod_python and PyWPS, and all the time I was using GET as HTTP request.

The WPS needs for some requests to be in the form of XML file so there is a need to implement POST to send such requests, for start I decided to try using POST to fetch some Key-Value-Pair.

I used the util class of mod_python as usual to deal with the request (as indicated on the mod_python tutorial:

form=util.FieldStorage(req)

But the form list was empty, tried so many things and so many possibilities like

request_made=req.read()

The only thing I was getting was a null reply, everything empty !!!

I found a post in the mod_python mailing-list with the same problem but no answer....and nothing on the specifications of mod_python.

Finally I discovered the problem !!!! POST was always empty because of PythonHandler mod_python.publisher and by dropping it and using my script file (wps2.py) as handler (PythonHandler wps2)the problem got solved. So the conclusion is: DON'T USE Publisher handler + POST together.

Also there is a huge lack of info on this POST "problem"!!!! This should be referred in the documentation !!!!

Labels: , , , ,

2 Comments:

At 27/4/08 2:06 AM, Blogger Abe said...

Hey,

My project group is having troubles with mod_python and POST requests as well. We are using the default publisher handler. We get an HTTP 501 "Method not implemented" error. Do you think I could get a copy of your handler script? Thanks in advance.

 
At 28/4/08 8:44 AM, Blogger Mister Jesus said...

Hi this is the Apache httpd.conf part:

<Directory "/usr/local/apache2/htdocs">
Order allow,deny
Allow from all
AddHandler mod_python .py
PythonHandler wps
PythonDebug On
</Directory>

My request is handled by a script called wps.py.

It is extremely simple to get the POST body (in my case an XML file). Inside the handle(req) function you just to use the read method:

PostContent=req.read()

Jorge

 

Post a Comment

<< Home