[patch] accented characters in MultiListFields

David Coe <[email protected]> Mon, 15 Nov 2004 13:30:34 -0500
Newsgroups gmane.comp.web.zope.formulator.devel
Message-ID <[email protected]>
Hi,

I maintain the Formulator package (zope-formulator) for Debian, and
one of our users reported the following problem and supplied a small
patch that seems to work.

Is there a better way to correct this?  If this change might cause
harm, please let me know so I can back it out.

Thanks.

Jerome Alet <[email protected]> wrote:

> I've created a form with both ListFields and MultiListFields

> All fields have the validator/unicode checkbox checked

> In ListFields, if I select an entry which contains accented
> characters (stored as UTF-8 in the field definition), then
> it works like a charm

> In MultiListFields, if I do the same, the entry is rejected
> with message "You selected an item that was not in the list."

> Solution, which seems to work : [...]

--- zope-formulator-1.7.0.orig/Validator.py
+++ zope-formulator-1.7.0/Validator.py
@@ -485,7 +485,7 @@
             if int_value is not None and value_dict.has_key(int_value):
                 result.append(int_value)
                 continue
-            if value_dict.has_key(value):
+            if value_dict.has_key(str(value)):
                 result.append(value)
                 continue
             self.raise_error('unknown_selection', field)


The original bug report in Debian is
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=253430
but there's not much more there than what's above.

Thanks.