[mod_python] form POST, redirect to GET, lost POST

Ezequiel Panepucci epanepucci at gmail.com
Wed Jun 6 07:14:42 EDT 2007


Client:
 * Firefox 2.0.0.3

Server:
 * httpd: Apache 2.2.4
 * mod_python: 3.3.1
 * python 2.5

Hi There,

I have a <form method="post" action="/pyweb"> (see below for
httpd.conf). The "/pyweb" maps to "/pyweb/index.py" which contains
a "def index(req)".

When I submit the form, my httpd access_log shows:
*.*,*,* - - [date] "POST /pyweb HTTP/1.1" 301 241
*.*,*,* - - [date] "GET /pyweb/ HTTP/1.1" 302 62

In the end, the "def index(req)" never sees what was POSTed.

I understand that the POST form is lost when the request is turned
into GET by misbehavior of my trusty browser (see section 10.3.2 in
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)

The workaround is to have action="/pyweb/" as opposed
to  action="/pyweb" so I prevent the "301".

Question: Is there a way to configure httpd or mod_python
so I do not have to worry about making sure that an ending
'/' is added to the action attribute of forms?

Thanks much for any comments.

Cheers,
   Zac

###########
########### httpd.conf
###########

Alias /pyweb /home/local/pyweb
<Directory "/home/local/pyweb">
    SetHandler python-program
    PythonHandler mod_python.publisher
    PythonDebug On

    Order allow,deny
    Allow from all
</Directory>


More information about the Mod_python mailing list