[Grok-dev] Re: Understanding unicode

Philipp von Weitershausen philipp at weitershausen.de
Fri Aug 31 16:32:29 EDT 2007


Jan Ulrich Hasecke wrote:
> zope.configuration.xmlconfig.ZopeXMLConfigurationError: File 
> "/Users/juh/GrokZoo/parts/app/site.zcml", line 4.0-4.29
>     ZopeXMLConfigurationError: File 
> "/Users/juh/GrokZoo/src/grokzoo/configure.zcml", line 4.2-4.27
>     UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in 
> position 7: ordinal not in range(128)

I think I understand what the problem is. The error message says it 
can't *encode* a unicode character. That means it's trying to conver it 
to a bytes string (not the other way around).

I suspect this is a limiatation of the Choice field and the 'values' 
parameter. It wants to be able to get a bytes representation of all 
items in the choice. Trying to use the ascii encoding, it obviously 
fails. This can be seen as a bug of the Choice field.

A workaround would be to use a source (or vocabulary) where the value of 
can be different from the display item and the token used in forms. 
Christian already pointed out how to write a simple source with 
zc.sourcefactory.


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the Grok-dev mailing list