[mod_python] query_vars and form_vars

Jorey Bump list at joreybump.com
Tue Jul 6 01:56:40 EDT 2004

Jorey Bump wrote:

> mod_python user wrote:
>> I would like to be able to retrieve both _form_ and _query_ 
>> variables, even if they share the same name. e.g.
>> <form method='post' action='/?name=NAME_ONE'> <input type='hidden' 
>> name='name' value='NAME_TWO' /> <input type='submit' /> </form>
>> It seems that when both a GET and POST variable share the same name
>>  that the GET (query) variable always wins.
>> Does anybody know how this might be accomplished?
> I don't know about servlets, but mod_publisher returns a list:

Duh. I mean mod_python.publisher. :P

> I don't know what causes this behaviour. Since only a POST request is
> sent, not a GET, I would expect any arguments in the URL to be 
> ignored and only variables in the message body to be recognized.

FWIW, mod_php ignores the URL arguments:

  Array ( [name] => NAME_TWO )

This seems more appropriate. A user shouldn't be allowed to mess with 
POST data so easily.

If this gets fixed (assuming it's a bug), you can still use 
req.unparsed_uri and do your own parsing. For example, use publisher and 
create foo.py with this function:

  def test(req):
      return req.unparsed_uri

Then view the results at:


Extract whatever you want from the resulting string.

More information about the Mod_python mailing list