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

Graham Dumpleton graham.dumpleton at gmail.com
Wed Jun 6 07:28:15 EDT 2007


On 06/06/07, Ezequiel Panepucci <epanepucci at gmail.com> wrote:
> 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.

The trailing slash is actually very important. If your browser isn't
told that it must be there then all your relative page references can
be screwed up. Thus, you don't really have a choice but to ensure it
is there.

That said, I would highly discourage you from using a directory as a
target of a form post. Instead be explicit and use /pyweb/index.py
instead as target of form.

Any particular reason why you wouldn't want to do that?

Graham

> 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>
> _______________________________________________
> 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