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

Mike Looijmans nlv11281 at natlab.research.philips.com
Mon Mar 13 03:56:47 EST 2006


Objections:
1. GET and POST are really, really bad names.
2. You already have what you want, you're just making things complex.

Explanation:
1. A GET request differs from a POST request in more ways than just 
"where the parameters are". A POST instructs the browser to "not do it 
again" on reload, because a POST has a side-effect (it changes data on 
the server). A GET is a read-only action that does not affect server 
state and can be issued as many times as desired.

2. On what you call a "nameclash", FieldStorage will put the req.args in 
req['title'][0] and the body version in req['title'][1].

I don't see why the whole mod_python community should adapt to your 
single solution to your particular 'problem'. I can think of about a 
dozen ways to get what you apparently want, and modifying any underlying 
mod_python code is not part of any of them.


Mike Looijmans
Philips Natlab / Topic Automation


Frédéric Jolliton wrote:
> Hi,
> 
> [..]
> 
>>>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
> want.)
> 
> 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>
> </fieldset>
> </form>
> 
> 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 ? :)
> 



More information about the Mod_python mailing list