[Grok-dev] Recipe - How to create a vocabulary that allows the
display of non-ASCII characters
Sebastian Ware
sebastian at urbantalk.se
Fri Sep 28 09:30:23 EDT 2007
Thanks for the info! This looks like a nice solution.
Mvh Sebastian
28 sep 2007 kl. 15.18 skrev Christian Theune:
> Am Montag, den 24.09.2007, 14:01 +0200 schrieb Sebastian Ware:
>> I just want to pitch my idea of what a recipe might look like. In
>> this case showing how to create a vocabulary that displays unicode
>> titles.
>
> FYI. Vocabularies are a broken technologie. Sources are better as they
> meet the background abstractions at the right points. The
> zc.sourcefactory package makes it more accessible:
>
> class MySource(zc.sourcefactory.basic.BasicSourceFactory):
>
> def getValues(self):
> theQuery = query.Eq(('workflow_catalog', 'workflow_state'),
> interfaces.PUBLISHED)
> return query.query.Query().searchResults(theQuery)
>
> def getTitle(self, value):
> return value.title
>
> def getToken(self, value):
> # This method is optional and I just put it here to demonstrate
> # the sourcefactory.
> return value.iso_code
>
> Then in your field definition you can do:
>
> country = Choice(title=u"Country", source=MySource())
>
> Christian
>
> --
> gocept gmbh & co. kg - forsterstrasse 29 - 06112 halle/saale - germany
> www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
> fax +49 345 122 9889 1 - zope and plone consulting and development
>
More information about the Grok-dev
mailing list