Back to index

plone3  3.1.7
Public Member Functions
plone.app.vocabularies.types.PortalTypesVocabulary Class Reference

List of all members.

Public Member Functions

def __call__

Detailed Description

Vocabulary factory for portal types.

  >>> from zope.component import queryUtility
  >>> from plone.app.vocabularies.tests.base import DummyContext
  >>> from plone.app.vocabularies.tests.base import DummyTypeTool

  >>> name = 'plone.app.vocabularies.PortalTypes'
  >>> util = queryUtility(IVocabularyFactory, name)
  >>> context1 = DummyContext()
  >>> context2 = DummyContext()
  >>> context1.context = context2

  >>> util(context1) is None
  True

  >>> context2.portal_types = DummyTypeTool()

  >>> types = util(context1)
  >>> types
  <zope.schema.vocabulary.SimpleVocabulary object at ...>

  >>> len(types.by_token)
  2

  >>> doc = types.by_token['Document']
  >>> doc.title, doc.token, doc.value
  ('Page', 'Document', 'Document')

Definition at line 105 of file types.py.


Member Function Documentation

Definition at line 136 of file types.py.

00136 
00137     def __call__(self, context):
00138         context = getattr(context, 'context', context)
00139         ttool = getToolByName(context, 'portal_types', None)
00140         if ttool is None:
00141             return None
00142         items = [ (ttool[t].Title(), t)
00143                   for t in ttool.listContentTypes() ]
00144         items.sort()
00145         items = [SimpleTerm(i[1], i[1], i[0]) for i in items]
00146         return SimpleVocabulary(items)

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: