Back to index

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

List of all members.

Public Member Functions

def __call__

Detailed Description

Vocabulary factory for allowable content types.

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

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

  >>> tool = DummyTool('portal_transforms')
  >>> def listAvailableTextInputs():
  ...     return ('text/plain', 'text/spam')
  >>> tool.listAvailableTextInputs = listAvailableTextInputs
  >>> context2.portal_transforms = tool

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

  >>> len(types.by_token)
  2

  >>> doc = types.by_token['text/plain']
  >>> doc.title, doc.token, doc.value
  ('text/plain', 'text/plain', 'text/plain')

Definition at line 11 of file types.py.


Member Function Documentation

Definition at line 43 of file types.py.

00043 
00044     def __call__(self, context):
00045         context = getattr(context, 'context', context)
00046         items = list(getAllowableContentTypes(context))
00047         items.sort()
00048         items = [SimpleTerm(i, i, i) for i in items]
00049         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: