[Web-SIG] Random thoughts

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Nov 3 15:29:25 EST 2003


On Mon, 3 Nov 2003, Ian Bicking wrote:

> On Nov 3, 2003, at 9:07 AM, Gregory (Grisha) Trubetskoy wrote:
> >
> > request.form(query_overrides=1)   <-- returns both
> > request.form.postdata()
> > request.form.querydata()
>
> Seems a little long-winded.  How about request.formdata, .postdata,
> .querydata, where .formdata is postdata+querydata?  (In practice most
> people use the combined version)

I'd say -1 on postdata and querydata, because request.postdata sounds to
me like the body of the POST and querydata sounds like the "stuff after
question mark". The word "form" has to be in there.

> They could be proper dictionary-like objects.

Of course. To elaborate on what I had in mind (the above, btw, has an
error - form() cannot be both a method and an object):

request.form() would return a mapping object (aka dictionary-like)
containing both post and query data.

[At this point I'd like to backtrack on my prior statement - query data
should not override post data or vice versa, they should probably be
combined, just like they would if there were multiple form inputs by the
same name - so perhaps we don't even need to override option at all]

If you want only post data, you'd need to call request.form().postdata()

So most everyone's code would look like:

    myform = request.form()

While some people may use:

  myform = request.form().postdata()


Also, form() *has* to be a method for this reason:

In case of POST, availability of form data implies that something consumes
(reads) the request. Some people would prefer to read it themselves. A
(first) call to form() would trigger this action, after which there
wouldn't be anything to read. Otherwise you could read it with
request.read().


Grisha



More information about the Web-SIG mailing list