AW: [Zope-dev] z3c.form SequenceWIdget extract

Mat Lehmann mat at matlehmann.de
Fri Mar 14 11:37:50 EDT 2008


Roger Ineichen schrieb:
> Hi Mat
>   
> Can you give a smaple ot the search string which you are using
> if it contains a sequence widget? I guess this string is wrong
> and this ends in none sequence data at the server side.
> If I'm right, now you are trying to convert this simple data
> string into a sequence, right?
>
> Try to build a sequence of values as:
>
> search.html?text=foo&text=bar
>
> that's the right way to send sequence data and will give you 
> the result:
>
> text = ['foo', 'bar']
>
> at the server side.
>   

Hi Roger,

I am sorry, but I was not clear enough with my description:

In my search-form, I have a simple single-select-widget (i.e. a 
dropdown). My problem is not to transmit multiple values for a single 
widget over a GET-paramter-string - for this, your solution should work.
But I want to use the key and value of this dropdown-widget just the 
same way as for input-widgets:
I want to be able to build a query-string like

search.html?form.widgets.dropdown=foo

and have the SequenceWidget accept this single value. Currently, 
SequenceWidget depends on the fact, that in the templates for 
sequence-widgets, the name of the widget gets a postfix of ":list" (so 
"form.widgets.dropdown" is now "form.widgets.dropdown:list") and because 
of that, the value is transformed to a list by 
zope.publisher.browser.BrowserRequest.

But because the method in my application that builds the query-string 
has no knowledge about the widget-types - it simple has key-value-pairs 
- it can not append the ":list" postfix to the paramter name, thus the 
value is not transformed to a list and SequenceWidget disregards the 
value altogether.

With the two additional lines, SequenceWidget does not assume anymore, 
that value has already been transformed to a list (a bold assumtion as I 
think, since it depends on the default templates) and it will accept 
query-strings of the given form.

Regards,

Mat


More information about the Zope-Dev mailing list