Back to index

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

List of all members.

Public Member Functions

def __call__

Detailed Description

Vocabulary factory for allowed 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.AllowedContentTypes'
  >>> 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

  >>> tool = DummyTool('portal_properties')
  >>> class DummyProperties(object):
  ...     def hasProperty(self, value):
  ...         return True
  ...
  ...     def getProperty(self, value):
  ...         return ('text/spam', )
  >>> tool.site_properties = DummyProperties()
  >>> context2.portal_properties = tool

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

  >>> len(types.by_token)
  1

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

Definition at line 53 of file types.py.


Member Function Documentation

Definition at line 95 of file types.py.

00095 
00096     def __call__(self, context):
00097         context = getattr(context, 'context', context)
00098         items = list(getAllowedContentTypes(context))
00099         items.sort()
00100         items = [SimpleTerm(i, i, i) for i in items]
00101         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: