[Grok-dev] Recipe - How to create a vocabulary that allows the
display of non-ASCII characters
Christian Theune
ct at gocept.com
Fri Sep 28 09:18:37 EDT 2007
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20070928/22d4ccc7/attachment.bin
More information about the Grok-dev
mailing list