[twill] Twill not capable of handling multiple form fields with the same name?
jeff at bitprophet.org
Tue Apr 18 11:54:45 PDT 2006
Been using twill quite happily for a while, and ran into a problem
today. I don't think it's exactly twill's fault, but I'm hoping
someone else might have ideas that have thus far eluded me.
I have a bunch of forms that I am testing with twill, specifically
some new ones which include a custom control; it consists of three
dropdowns corresponding to the month, day and year of your average
Due to the way that my Web framework of choice (Django) handles form
input, I had to give all three dropdowns the same "name" attribute. I
don't recall if this is explicitly allowed or forbidden by the
protocols that be, but it works and I've seen it used in various
places without problems (i.e. this isn't a Django-specific oddity by
Basically, the framework code that receives the POST data makes lists
out of everything, and if it sees the same "name" attribute more than
once, the resulting POST dictionary value becomes a multi-item list.
So my date control ends up looking something like ["04","18","2006"].
Unfortunately, the form driver twill uses--ClientForm--disagrees with
this approach, and throws nasty errors when I try to simulate setting
those dropdowns. It seems to take the last dropdown as "the" form
control for the given name. This presents problems when I want to
simulate setting *all three* of them to various values, and at any
rate it trips up my own validation code which expects a list of three
items and instead ends up getting POSTed only a single-item list.
["2006"] does not a full date make.
The only solution that has presented itself to me (other than simply
not testing any forms on my site which use date controls...which will
be many) is to wade into the ClientForm code and hack it to support
"my" way of doing things. Can anyone think of something else I could
try before I commit to this? Is there something I should be doing
differently in my usage of twill?
Thanks for any help,
More information about the twill