[Zope3-Users] DropdownWidget with SimpleVocabulary causes
ConversionError.
wata at kke.biglobe.ne.jp
wata at kke.biglobe.ne.jp
Sun Mar 26 21:52:16 EST 2006
Hi,
I got a ploblem with SimpleVocabulary/SimpleTerm.
Here is the situation of that.
(1) I used Zope3.2 on Windows XP.
(2) I made :
a vocabulary, and
a Choice field with the vocabulary, and
a schema contains the field, and
an add-form using the schema.
(3) the vocabulary was made using SimpleVocabulary.fromValues().
with values which are all unicode strings(japanese).
(4) I got an error, when I pressed "Add" button of the add-form.
I had selected one of the item of DropdownWidget. Any item
of the widget caused the same error.
(5) The error was raised at line 160 in
zope/app/form/browser/itemswidgets.py
ConversionError("Invalid value", e)
After I got the error, I went through the relevant code.
I think that is the things happend.
(1) SimpleTerm's '__init__' method makes the type of its
'token' attribute to 'str' always.
(2) on the other hand, DropdownWidget extract the token from
the term in the vocabulary, and convert to 'unicode' in
'renderElement' method in zope/app/form/browser/widgets.py.
and HTML that zope3 produces is always utf-8.
(3) When the item(originally the token of the term) of
DropdownWidget gets back in the request, it is 'unicode'.
(4) the input value in the request is 'unicode', and
the token within the SimpleVocabulary is always 'str'.
so, the vocabulary can't find the corresponding term,
and raises the ConversionError.
Do you think that is a bug? or do I misuse SimpleVocabulary?
Any help appreciated.
Regards,
Katsutoshi
--
Watanabe, Katsutoshi
# I beg you to point out the error or rudeness of my english.
# Thank you.
More information about the Zope3-users
mailing list