[mod_python] select multiple

Adrien Plisson aplisson-modpython at stochastique.net
Wed Aug 25 16:51:49 EDT 2004


sector119 at mail.ru wrote:
> hi

hello !

> I use publisher handler. When I do:
> for k in req.form.keys():
>     req.write(repr(k)+" - "+repr(req.form[k])+"\n")
> 
> it does not show list of lists at "select multiple"!
> just 'manufacturers' - ['13', '18', '14', '17', '13', '14', '17'] not
> 'manufacturers' - [['13', '18'], ['14', '17', '13'], ['14', '17']]
> 
> why?
> 

well, simple answer: because req.form[k] do contain a list and not a list of 
lists...

more elaborated: you can try this in a python interpreter:
 >>> a = [1,2]
 >>> a += [2,3]
 >>> a
[1, 2, 2, 3]
notice that a does just contain a list. the + operator on a list is not a 
simple concatenation !!

but if you type:
 >>> a = [1,2]
 >>> a.append( [2,3] )
 >>> a
[1, 2, [2, 3]]
notice a contains a list of list. the append method of list IS a concatenation.

there may be a bug somewhere in mod_python, or you may have mistyped your 
concatenation...

hope this helps !

-- 
rien


More information about the Mod_python mailing list