Back to index

plone3  3.1.7
Public Member Functions
plone.app.vocabularies.skins.SkinsVocabulary Class Reference

List of all members.

Public Member Functions

def __call__

Detailed Description

Vocabulary factory for skins.

  >>> 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.Skins'
  >>> util = queryUtility(IVocabularyFactory, name)
  >>> context1 = DummyContext()
  >>> context2 = DummyContext()
  >>> context1.context = context2

  >>> util(context1) is None
  True

  >>> tool = DummyTool('portal_skins')
  >>> def getSkinSelections():
  ...     return ('Plone Default', 'Plone Kitty')
  >>> tool.getSkinSelections = getSkinSelections
  >>> context2.portal_skins = tool

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

  >>> len(skins.by_token)
  2

  >>> de = skins.by_token['Plone Kitty']
  >>> de.title, de.token, de.value
  ('Plone Kitty', 'Plone Kitty', 'Plone Kitty')

Definition at line 8 of file skins.py.


Member Function Documentation

Definition at line 43 of file skins.py.

00043 
00044     def __call__(self, context):
00045         context = getattr(context, 'context', context)
00046         stool = getToolByName(context, 'portal_skins', None)
00047         if stool is None:
00048             return None
00049         items = list(stool.getSkinSelections())
00050         items.sort()
00051         items = [SimpleTerm(i, i, i) for i in items]
00052         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: