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

Frédéric Jolliton mod_python at frederic.jolliton.com
Mon Mar 13 12:45:33 EST 2006

[Since everyone is top posting, I will don't take the time to
copy&paste parts of my previous post for the context..]

To summarize, I'm proposing:

util.FieldStorage()                   # as usual, return all fields
util.FieldStorage( source = 'all' )   # same as above
util.FieldStorage( source = 'query' ) # only fields from QS
util.FieldStorage( source = 'post' )  # only fields from POST method

> Objections:
> 1. GET and POST are really, really bad names.

I agree. Then perhaps something like source='query' and source='post',
defaulting to source='all' (see above.)

> 2. You already have what you want, you're just making things
> complex.

I want more control, more possibility, more power. I don't see
complexity here.

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

You're talking about web browsers and HTML. That's only conventions.
You seems to imply that's the only way. But we agree on the different
meaning according to the origin, and that's the reason for my patch.

But even the query string is only convention (it could be any string
with any syntax you want) as long as it doesn't come from a form with
GET method !

So, here is another (contrived) example:

Say I've my own syntax for the "query" string where & and = have
potentially different meaning (that's my right), and I use only POST
method for forms.

I've URLs such as:




(base64 encoded values)

or.. well, lot of other possible example for whatever reasons.

However, I want to process the POST fields normally, so in such case I
could want to do:

# Process the query string with my own syntax separately
data = processMyOwnSyntax( req.subprocess_env[ 'QUERY_STRING' ] )

# Reuse the useful util.FieldStorage for the POST fields only and
# don't try to parse query string because the data don't come from a
# form.
formFields = util.FieldStorage( source = 'post' )

> 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].

Seriously ? :) How could you build serious stuff by relying on such
detail !

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

Sure, I can just create my own FieldStorage class anyway. After all,
I'm only suggesting something. That such a change could be part of
mod_python or not is not a big concern to me.

And english is not my primary language, it's hard to me to explain
things correctly.

Frédéric Jolliton

More information about the Mod_python mailing list