[Web-SIG] Form field dictionaries

Steve Holden sholden at holdenweb.com
Fri Oct 24 14:52:20 EDT 2003


> -----Original Message-----
> From: web-sig-bounces+sholden=holdenweb.com at python.org
> [mailto:web-sig-bounces+sholden=holdenweb.com at python.org]On Behalf Of
> David Fraser
> Sent: Friday, October 24, 2003 2:01 PM
> To: Ian Bicking
> Cc: web-sig at python.org
> Subject: Re: [Web-SIG] Form field dictionaries
>
>
> Ian Bicking wrote:
>
> > On Friday, October 24, 2003, at 11:28 AM, David Fraser wrote:
> >
> >> That's fine, but I think it's important that these methods are
> >> available as an addition to a standard dictionary interface.
> >> I think the key point is, if somebody wants a list of values, they
> >> probably know that they want a list.
> >> It's very difficult to write code by accident that would handle a
> >> list of values as well as a string.
> >> So if somebody knows they want a list in certain
> circumstances, they
> >> could call getlist()
> >> But I think the default dictionary return value should be
> the same as
> >> getfirst().
> >> That saves endless checks for lists for those who don't need them.
> >
> >
> > Every time I have encountered an unexpected list it has
> been because
> > of a bug somewhere else in my code.  I might use a getone() method
> > that threw some exception when a list was encountered, but
> I'd *never*
> > want to use getfirst().  getfirst() is sloppy programming.
> (getlist()
> > is perfectly fine though)
>
> There seems to be a lot of agreement on this...
> So let's take it that the interface will be a dictionary,
> with an extra
> method defined, getlist, which will return multiple items if multiple
> items were defined, or a list containing a single item otherwise.
> The next question is, how do we handle the Get/Post/Both situation?
> One way would be to have methods on the request object that
> return the
> desired dictionary
> Somebody also suggested including Cookies, as is done in PHP
> - I'm not
> sure this is a good idea
>
The only nit I would pick is to have getlist() return a list even when
the response contained a single value.

regards
--
Steve Holden          +1 703 278 8281        http://www.holdenweb.com/
Improve the Internet           http://vancouver-webpages.com/CacheNow/
Python Web Programming                http://pydish.holdenweb.com/pwp/
Interview with GvR August 14, 2003       http://www.onlamp.com/pytho





More information about the Web-SIG mailing list