Back to index

plone3  3.1.7
Public Member Functions
plone.app.vocabularies.workflow.WorkflowsVocabulary Class Reference

List of all members.

Public Member Functions

def __call__

Detailed Description

Vocabulary factory for workflows.

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

  >>> util(context1) is None
  True

  >>> class Workflow(object):
  ...     def __init__(self, id, title):
  ...         self.id = id
  ...         self.title = title

  >>> tool = DummyTool('portal_workflow')
  >>> def objectValues():
  ...     return (Workflow('default', 'Default Workflow'),
  ...             Workflow('intranet', 'Intranet Workflow'))
  >>> tool.objectValues = objectValues
  >>> context2.portal_workflow = tool

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

  >>> len(workflows.by_token)
  2

  >>> intranet = workflows.by_token['intranet']
  >>> intranet.title, intranet.token, intranet.value
  ('Intranet Workflow', 'intranet', 'intranet')

Definition at line 13 of file workflow.py.


Member Function Documentation

Definition at line 54 of file workflow.py.

00054 
00055     def __call__(self, context):
00056         context = getattr(context, 'context', context)
00057         wtool = getToolByName(context, 'portal_workflow', None)
00058         if wtool is None:
00059             return None
00060         items = [(w.title, w.id) for w in wtool.objectValues()]
00061         items.sort()
00062         items = [SimpleTerm(i[1], i[1], i[0]) for i in items]
00063         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: