On Jul 16, 2010, at 8:53 AM, ae wrote: > I never said request.vars is a list. > > If I have a multiple select box on a page and one entry is selected > then I get a string. If multiple entries are selected, I get a list > of strings. That's not good. > > <select multiple name="things"> > <option value="one">One</option> > <option value="two">Two</option> > <option value="three">Three</option> > <option value="four">Four</option> > </select> > > request.vars.things could be something like "two" or like ["one", > "four"]. > > Which means I have to figure out ahead of time whether the user > selected one item or more than one item: > > if not isinstance(request.vars.things, list): > request.vars.things = [request.vars.things]
At the very least you might encapsulate this logic into a global function. for thing in tolist(request.vars.things): print thing > > So that I can loop naturally: > > for thing in request.vars.things: > print thing > > Otherwise, my loop will iterate over the string such as ['o', 'n', > 'e']. > > It seems that if one is not using the built-in ORM, this framework may > not be a good solution. > > > On Jul 16, 10:14 am, Vasile Ermicioi <elff...@gmail.com> wrote: >> request.vars is not a list, it is an object which have properties >> it is like a dict not like a list >> >> and list(request.vars) is a list of properties, not of values >> >> like dict().keys()