[Zope3-Users] DropdownWidget with SimpleVocabulary causes ConversionError.

Michael Howitz mh at gocept.com
Mon Mar 27 02:11:08 EST 2006


Am Montag, den 27.03.2006, 11:52 +0900 schrieb wata at kke.biglobe.ne.jp: 
> 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).

Hi,

Vocabularies hav three levels:
value: which is stored in ZODB
token: which is used as value attribute of the option tag in HTML-Page.
It must be convertable to str with ASCII encoding because when the
conversion is done the encoding of the page is not yet known. (Correct
me if I'm wrong here)
title: which is dislpayed to the user as the contents of the option tag

SimpleVocabulary.fromValues uses the values as value, token and title,
so it is only useable with ASCII values.

So you have to do it like this way:
SimpleVocabulary(SimpleTerm(<value>, <token>, <title>), ...)

token might be the uid of value, if it is an object which is stored in
ZODB.

-- 
mac



More information about the Zope3-users mailing list