Commit 25a25094 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Better handling of validate and invoke


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@742 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 250b51a0
...@@ -64,11 +64,15 @@ class RAMQueue(Queue): ...@@ -64,11 +64,15 @@ class RAMQueue(Queue):
def dequeueMessage(self, activity_tool, processing_node): def dequeueMessage(self, activity_tool, processing_node):
if len(self.getQueue(activity_tool)) is 0: if len(self.getQueue(activity_tool)) is 0:
return 1 # Go to sleep return 1 # Go to sleep
m = self.getQueue(activity_tool)[0] if not m.validate(self, activity_tool):
self.deleteMessage(activity_tool, m) # Trash messages which are not validated (no error handling)
get_transaction().commit()
return 0 # Keep on ticking
activity_tool.invoke(m) activity_tool.invoke(m)
self.deleteMessage(activity_tool, m) if m.is_executed:
self.deleteMessage(activity_tool, m) # Trash messages which are not validated (no error handling)
get_transaction().commit() get_transaction().commit()
return 0 # Keep on ticking return 0 # Keep on ticking
def hasActivity(self, activity_tool, object, **kw): def hasActivity(self, activity_tool, object, **kw):
object_path = object.getPhysicalPath() object_path = object.getPhysicalPath()
...@@ -81,13 +85,27 @@ class RAMQueue(Queue): ...@@ -81,13 +85,27 @@ class RAMQueue(Queue):
# Parse each message in registered # Parse each message in registered
for m in activity_tool.getRegisteredMessageList(self): for m in activity_tool.getRegisteredMessageList(self):
if object_path == m.object_path and (method_id is None or method_id == m.method_id): if object_path == m.object_path and (method_id is None or method_id == m.method_id):
if invoke: activity_tool.invoke(m) if not m.validate(self, activity_tool):
activity_tool.unregisterMessage(self, m) activity_tool.unregisterMessage(self, m) # Trash messages which are not validated (no error handling)
else:
if invoke:
activity_tool.invoke(m)
if m.is_executed:
activity_tool.unregisterMessage(self, m)
else:
activity_tool.unregisterMessage(self, m)
# Parse each message in queue # Parse each message in queue
for m in self.getQueue(activity_tool): for m in self.getQueue(activity_tool):
if object_path == m.object_path and (method_id is None or method_id == m.method_id): if object_path == m.object_path and (method_id is None or method_id == m.method_id):
if invoke: activity_tool.invoke(m) if not m.validate(self, activity_tool):
self.deleteMessage(activity_tool, m) activity_tool.deleteMessage(self, m) # Trash messages which are not validated (no error handling)
else:
if invoke:
activity_tool.invoke(m)
if m.is_executed:
activity_tool.deleteMessage(self, m) # Only delete if no error happens
else:
activity_tool.deleteMessage(self, m)
def getMessageList(self, activity_tool, processing_node=None): def getMessageList(self, activity_tool, processing_node=None):
new_queue = [] new_queue = []
......
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