src/pyams_workflow/workflow.py
changeset 4 08e003da5f9e
parent 3 709aec888463
child 11 f25326715002
equal deleted inserted replaced
3:709aec888463 4:08e003da5f9e
    25 from pyams_utils.registry import get_utility
    25 from pyams_utils.registry import get_utility
    26 from pyams_utils.request import check_request
    26 from pyams_utils.request import check_request
    27 from pyams_utils.traversing import get_parent
    27 from pyams_utils.traversing import get_parent
    28 from pyramid.httpexceptions import HTTPUnauthorized
    28 from pyramid.httpexceptions import HTTPUnauthorized
    29 from pyramid.threadlocal import get_current_registry
    29 from pyramid.threadlocal import get_current_registry
       
    30 from zope.componentvocabulary.vocabulary import UtilityVocabulary
    30 from zope.interface import implementer
    31 from zope.interface import implementer
    31 from zope.lifecycleevent import ObjectModifiedEvent
    32 from zope.lifecycleevent import ObjectModifiedEvent
       
    33 from zope.schema.vocabulary import getVocabularyRegistry
    32 
    34 
    33 
    35 
    34 def NullCondition(wf, context):
    36 def NullCondition(wf, context):
    35     """Null condition"""
    37     """Null condition"""
    36     return True
    38     return True
   245         state = IWorkflowState(self.context)
   247         state = IWorkflowState(self.context)
   246         transitions = self.wf.get_transitions(state.state)
   248         transitions = self.wf.get_transitions(state.state)
   247         # now filter these transitions to retrieve all possible
   249         # now filter these transitions to retrieve all possible
   248         # transitions in this context, and return their ids
   250         # transitions in this context, and return their ids
   249         return [transition for transition in transitions if transition.trigger == trigger]
   251         return [transition for transition in transitions if transition.trigger == trigger]
       
   252 
       
   253 
       
   254 class WorkflowsVocabulary(UtilityVocabulary):
       
   255     """Workflows vocabulary"""
       
   256 
       
   257     interface = IWorkflow
       
   258     nameOnly = True
       
   259 
       
   260 getVocabularyRegistry().register('PyAMS workflows', WorkflowsVocabulary)