[Grok-dev] Sample code creating and registring a SimpleVocabulary?
Sebastian Ware
sebastian at urbantalk.se
Tue Aug 28 15:09:16 EDT 2007
So simple and elegant -- thank you very much!!! It took me a couple
of hours not to figure it out by myself... :)
Mvh Sebastian
28 aug 2007 kl. 17.49 skrev Kevin Smith:
> Here's one of the ways to do it.
>
> Kevin Smith
>
>
>
> from zope import schema
> from zope.schema.vocabulary import SimpleVocabulary
>
> VARIETALS = """Cabernet Franc
> Cabernet Sauvignon
> Chardonnay
> Chenin Blanc
> Claret
> Gewurztraminer
> Grenache
> Malbec
> Marsanne
> Merlot
> Petit Syrah
> Petit Verdot"""
>
> class VarietalsSource(object):
> def __call__(self, context):
> values = VARIETALS.splitlines()
> return SimpleVocabulary.fromValues(values)
> grok.global_utility(VarietalsSource,
> provides=schema.interfaces.IVocabularyFactory,
> name=u'VarietalsSource')
More information about the Grok-dev
mailing list