Added workflows vocabulary
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 May 2015 12:43:47 +0200
changeset 4 08e003da5f9e
parent 3 709aec888463
child 5 43c135a76ab2
Added workflows vocabulary
src/pyams_workflow/workflow.py
--- a/src/pyams_workflow/workflow.py	Wed Mar 18 10:10:59 2015 +0100
+++ b/src/pyams_workflow/workflow.py	Wed May 20 12:43:47 2015 +0200
@@ -27,8 +27,10 @@
 from pyams_utils.traversing import get_parent
 from pyramid.httpexceptions import HTTPUnauthorized
 from pyramid.threadlocal import get_current_registry
+from zope.componentvocabulary.vocabulary import UtilityVocabulary
 from zope.interface import implementer
 from zope.lifecycleevent import ObjectModifiedEvent
+from zope.schema.vocabulary import getVocabularyRegistry
 
 
 def NullCondition(wf, context):
@@ -247,3 +249,12 @@
         # now filter these transitions to retrieve all possible
         # transitions in this context, and return their ids
         return [transition for transition in transitions if transition.trigger == trigger]
+
+
+class WorkflowsVocabulary(UtilityVocabulary):
+    """Workflows vocabulary"""
+
+    interface = IWorkflow
+    nameOnly = True
+
+getVocabularyRegistry().register('PyAMS workflows', WorkflowsVocabulary)