[Web-SIG] Form field dictionaries
barry at python.org
Wed Oct 29 12:12:21 EST 2003
On Wed, 2003-10-29 at 10:11, Steve Holden wrote:
> If an argument has multiple values, this should only be handled if the
> processing element (page code) has indicated that multiple values are
> acceptable for that argument. When an argument is possibly multi-valued,
> form['fieldname'] should *always* be a list, even if it has only one
> element [and I don't see why it shouldn't be legal to see an empty list
> if the argument doesn't appear in the URL or POST input at all]. If no
> indication has been given that multiple occurrences are acceptable then
> an exception should be raised which, if not trapped by the web app,
> should eventually result in (say) a 422 (unprocessable entity) or a 406
> (not acceptable) server response.
I tend to agree with Steve here, but maybe we can have our cake and eat
Dumb-ass suggestion of the day: what if the field values were
represented by a dict subclass, and we had several different subclasses,
each of which specified the exact behavior for __getitem__(). E.g.
David could have his "_getitem__ is getfirst" behavior, Steve could have
his verified-multiples behavior, and I could have my "always return a
list" behavior. We'd then be reduced to choosing a default and a few
interfaces and everyone would be happy <wink>.
More information about the Web-SIG