Commit 054d5a21 authored by Aurelien Campeas's avatar Aurelien Campeas
Browse files

add postcommit_event on Operations

--HG--
branch : stable
parent d5bf894fcf02
......@@ -426,6 +426,7 @@ class WorkflowableMixIn(object):
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
......
......@@ -191,7 +191,7 @@ class Operation(object):
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 @@ class Operation(object):
operation list
"""
def postcommit_event(self):
"""the observed connections pool has committed"""
class PreCommitOperation(Operation):
"""base class for operation only defining a precommit operation
......
......@@ -467,6 +467,15 @@ class Session(RequestSessionMixIn):
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment