Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from plone import api
- from zope.interface import implementer
- from zope.schema.interfaces import IVocabularyFactory
- from zope.schema.vocabulary import SimpleTerm
- from zope.schema.vocabulary import SimpleVocabulary
- @implementer(IVocabularyFactory)
- class ExampleVocabularyVocabulary(object):
- """
- """
- def __call__(self, context):
- # as an example we create a vocabulary of all News Items items in the portal:
- items = [
- VocabItem(u'sony-a7r-iii', _(u'Sony Aplha 7R III')),
- VocabItem(u'canon-5d-iv', _(u'Canon 5D IV')),
- ]
- # create a list of SimpleTerm items:
- terms = []
- for item in items:
- terms.append(
- SimpleTerm(
- value=item.token,
- token=str(item.token),
- title=item.value,
- )
- )
- return SimpleVocabulary(terms)
- ExampleVocabularyVocabularyFactory = ExampleVocabularyVocabulary()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement