add postcommit_event on Operations stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 03 Dec 2009 11:39:31 +0100
branchstable
changeset 3986 cc29eddf51ad
parent 3985 d5bf894fcf02
child 3987 f85ef29f6214
add postcommit_event on Operations
entities/wfobjs.py
server/pool.py
server/session.py
--- a/entities/wfobjs.py	Thu Dec 03 10:02:44 2009 +0100
+++ b/entities/wfobjs.py	Thu Dec 03 11:39:31 2009 +0100
@@ -426,6 +426,7 @@
     def possible_transitions(self, type='normal'):
         """generates transition that MAY be fired for the given entity,
         expected to be in this state
+        used only by the UI
         """
         if self.current_state is None or self.current_workflow is None:
             return
--- a/server/pool.py	Thu Dec 03 10:02:44 2009 +0100
+++ b/server/pool.py	Thu Dec 03 11:39:31 2009 +0100
@@ -191,7 +191,7 @@
         return -(i + 1)
 
     def handle_event(self, event):
-        """delegate event handling to the opertaion"""
+        """delegate event handling to the operation"""
         getattr(self, event)()
 
     def precommit_event(self):
@@ -222,6 +222,9 @@
         operation list
         """
 
+    def postcommit_event(self):
+        """the observed connections pool has committed"""
+
 
 class PreCommitOperation(Operation):
     """base class for operation only defining a precommit operation
--- a/server/session.py	Thu Dec 03 10:02:44 2009 +0100
+++ b/server/session.py	Thu Dec 03 11:39:31 2009 +0100
@@ -467,6 +467,15 @@
                     self.rollback(reset_pool)
                     raise
             self.pool.commit()
+            self.commit_state = trstate = 'postcommit'
+            while self.pending_operations:
+                operation = self.pending_operations.pop(0)
+                operation.processed = trstate
+                try:
+                    operation.handle_event('%s_event' % trstate)
+                except:
+                    self.exception('error while %sing', trstate)
+            self.debug('%s session %s done', trstate, self.id)
         finally:
             self._touch()
             self.commit_state = None