[Grok-dev] Re: Understanding unicode

Philipp von Weitershausen philipp at weitershausen.de
Sun Sep 23 21:16:04 EDT 2007


Sebastian Ware wrote:
> A recipe for this would be very much appreciated, even if it is a bit 
> cumbersome :) Choice fields with only ascii representations are rather 
> limited with repect to usability.

Note that only the values=[] option is problematic here. If you're using 
a proper vocabulary, you're fine.

> I have had to use ISO-codes instead of 
> country names in a current project and it is not a very good solution.

Then you're ignoring the obvious solution: a vocabulary (or source). As 
long as you provide a token that's a pure-ASCII representation of the 
value, you're fine. You can use whatever you want for the values (even 
arbitrary objects). All you need is a one-to-one mapping from tokens to 
objects.

To create the vocabulary you can use SimpleVocabulary.fromItems() which 
takes a list of (token, value) pairs.


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


More information about the Grok-dev mailing list