Personal tools
You are here: Home Zope & Plone tips Creating and using vocabularies in Zope 3
Navigation
 
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Creating and using vocabularies in Zope 3

by tibi last modified 2007-06-27 11:13

def getActivityPhaseVocabulary(context):
    catalog = getUtility(ICatalog)
    items = catalog.searchResults(portal_type=("ActivityPhase", "ActivityPhase"))
    return SimpleVocabulary.fromValues([item.title for item in items])

  <utility name="coursebuilder.activity.phases"
    component=".vocabulary.getActivityPhaseVocabulary"
    provides="zope.schema.interfaces.IVocabularyFactory" />

More useful zcml

Posted by Anonymous User at 2009-03-30 18:09
If you use:

<utility name="coursebuilder.activity.phases"
factory=".vocabulary.getActivityPhaseVocabulary" />

Then, the IVocabularyFactory interface is assumed, and you can also use:

def getActivityPhaseVocabulary(context,**kwargs):

in your function definition, and add any parameters you want in the zcml:
<utility name="coursebuilder.activity.phases"
factory=".vocabulary.getActivityPhaseVocabulary"
firstParm="this"
secondParm="that"
/>

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: