Back to index

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

List of all members.

Public Member Functions

def __call__

Detailed Description

Vocabulary factory for really user friendly portal types.

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

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

  >>> util(context1) is None
  True

  >>> tool = DummyTypeTool()
  >>> tool['ATBooleanCriterion'] = DummyType('Boolean Criterion')
  >>> context2.portal_types = tool

  >>> 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 210 of file types.py.


Member Function Documentation

Definition at line 244 of file types.py.

00244 
00245     def __call__(self, context):
00246         context = getattr(context, 'context', context)
00247         ttool = getToolByName(context, 'portal_types', None)
00248         if ttool is None:
00249             return None
00250         items = [ SimpleTerm(t, t, ttool[t].Title())
00251                   for t in ttool.listContentTypes()
00252                   if t not in BAD_TYPES ]
00253         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: