[Grok-dev] zope.schema.Choice & unicode problem
    Christian Klinger 
    cklinger at novareto.de
       
    Wed Aug 25 09:29:52 EDT 2010
    
    
  
Hello Marcel,
you can use vocabularies instead of values. Take a look on this
example it should help you:
def voc(*terms):
    return SimpleVocabulary([SimpleTerm(value, token, title) for value, 
token, title in terms])
[...]
    colors=Choice(title=_(u"The color"),voc(
       ('Fehler','Fehler',u"Fehler"),
       ('Änderung','Änderung',u"Änderung")
    ))
Let me know if it works for you...
Christian
>
> I have a problem with my zope.schema.Choice in combination with
> unicode-values in one of my grok projects:
>
> q_type = zope.schema.Choice(title=u'Art', values=[u'Fehler', u'Änderung'])
>
> Basically, that works fine but since there is an 'Ä'-Umlaut inside the
> valuelist,
> Zope keeps me crashing while zope-server starts up:
>
>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in position
> 0: ordinal not in range(128)
>
> # coding=utf-8 is set in the scriptfile of course. Umlauts work perfect in
> "title" but not for "values".
>
> Any Idea what is causing the problem and how to solve it?
>
    
    
More information about the Grok-dev
mailing list