[mod_python] Re: Specifying GET/POST method for FieldStorage

Frédéric Jolliton mod_python at frederic.jolliton.com
Mon Mar 13 03:35:00 EST 2006


>> getFieldStorage = util.FieldStorage( from_method = 'GET' )
>> postFieldStorage = util.FieldStorage( from_method = 'POST' )

[GET/POST field storages]
> Can you explain why you would want to distinguish between the two?
> If trying to use the URL args and POST content args as different
> distinct input methods within the same request, it sounds a bit
> dodgy.

Not necessary.

Why ? Simply because I want to have full knowledge about the
values. And mainly because the meaning of the values is not the same
according to their origins !

A contrived example:

(I don't doubt someone will answer "Don't do that", but let say I

Say I've at http://example.com/books/?sort=author&title=full a form
like this:

<form method="POST" action="/books/?sort=author&amp;title=full">
<fieldset><legend> Add a book </legend>
               <input type="hidden" name="action" value="add-a-book" />
<p> Author:    <input type="entry"  name="author" /> </p>
<p> Title:     <input type="entry"  name="title" /> </p>
<p> Publisher: <input type="entry"  name="publisher" /> </p>
<p>            <input type="submit" name="submit" value="Add" /> </p>

Here, in this example, there is a clash because the query string
(which is kept from the original URL to maintain the parameters)
include 'title' and the form also include such a field with this name.

To summarize, in this example:

 - page parameters (query string) = ['sort', 'title']
 - form fields (post method) = ['action', 'author', 'title', 'publisher', 'submit']

However, and it's the point on my patch, I don't attach the same
semantic to query string values (which are there to "configure" the
current page) and to the post values (which are the result of the form
and which modify the contents or the resource or whatever) because to
me it's really 2 different *namespaces*, hence the need to parse them
into different field storages if necessary.

Does that make sense ?

After all, mod_python is about controlling every aspect of the
request, no ? :)

Frédéric Jolliton

More information about the Mod_python mailing list