[Product-Developers] Zope SimpleVocabulary Issue

Christian Thieme christian at lieblinx.net
Mon Jul 28 08:29:00 UTC 2008

i ran into an issue lately regarding the use of vocabularies in zope 3

>From the examples i saw i guessed that when i intialize an
SimpleVocabulary with the fromItems method and give it something like:

ZODIAC_SIGNS = 	((_(u"Aquarius"), "Aquarius"), 
	("Pisces"), "Pisces"),
        (_(u"Aries"), "Aries"),
        (_(u"Taurus"), "Taurus"),
        (_(u"Gemini"), "Gemini"), 
        (_(u"Cancer"), "Cancer"),
        (_(u"Leo"), "Leo"), 
        (_(u"Virgo"), "Virgo"), 
        (_(u"Libra"), "Libra"), 
        (_(u"Scorpio"), "Scorpio"),
        (_(u"Sagittarius"), "Sagittarius"), 
        (_(u"Capricorn"), "Capricorn"))

(_ is my MessageFactory as you may have guessed)

i should get a dropdown with the the value as the options value and
token displayed as options title. This didnt work, the token never
appeared and only the value was used to render the form.

When i use this instead:

terms = [SimpleTerm(sign[1], title=sign[0]) for sign in ZODIAC_SIGNS]
return SimpleVocabulary(terms)

it works as expected.

Did I misunderstand the use of SimpleVocabulary or is there a problem
with zope forms.


More information about the Product-Developers mailing list