[workflow hooks] reuse metadata/integrity categories instead of a new 'workflow' category and drop useless hook
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 02 May 2011 15:07:13 +0200
changeset 7294 2af1a4cecda5
parent 7293 97505b798975
child 7296 e559ade02665
[workflow hooks] reuse metadata/integrity categories instead of a new 'workflow' category and drop useless hook
hooks/workflow.py
--- a/hooks/workflow.py	Mon May 02 15:06:20 2011 +0200
+++ b/hooks/workflow.py	Mon May 02 15:07:13 2011 +0200
@@ -148,7 +148,7 @@
 
 class WorkflowHook(hook.Hook):
     __abstract__ = True
-    category = 'workflow'
+    category = 'metadata'
 
 
 class SetInitialStateHook(WorkflowHook):
@@ -160,21 +160,15 @@
         _SetInitialStateOp(self._cw, entity=self.entity)
 
 
-class PrepareStateChangeHook(WorkflowHook):
-    """record previous state information"""
-    __regid__ = 'cwdelstate'
-    __select__ = WorkflowHook.__select__ & hook.match_rtype('in_state')
-    events = ('before_delete_relation',)
+class FireTransitionHook(WorkflowHook):
+    """check the transition is allowed and add missing information into the
+    TrInfo entity.
 
-    def __call__(self):
-        self._cw.transaction_data.setdefault('pendingrelations', []).append(
-            (self.eidfrom, self.rtype, self.eidto))
-
-
-class FireTransitionHook(WorkflowHook):
-    """check the transition is allowed, add missing information. Expect that:
+    Expect that:
     * wf_info_for inlined relation is set
     * by_transition or to_state (managers only) inlined relation is set
+
+    Check for automatic transition to be fired at the end
     """
     __regid__ = 'wffiretransition'
     __select__ = WorkflowHook.__select__ & is_instance('TrInfo')
@@ -273,7 +267,7 @@
 
 
 class FiredTransitionHook(WorkflowHook):
-    """change related entity state"""
+    """change related entity state and handle exit of subworkflow"""
     __regid__ = 'wffiretransition'
     __select__ = WorkflowHook.__select__ & is_instance('TrInfo')
     events = ('after_add_entity',)
@@ -296,6 +290,7 @@
     __regid__ = 'wfcheckinstate'
     __select__ = WorkflowHook.__select__ & hook.match_rtype('in_state')
     events = ('before_add_relation',)
+    category = 'integrity'
 
     def __call__(self):
         session = self._cw