Commit 0f1290b3 authored by Julien Muchembled's avatar Julien Muchembled

CMFActivity: code simplification

parent 09c8f83f
...@@ -143,12 +143,10 @@ class Queue(object): ...@@ -143,12 +143,10 @@ class Queue(object):
return EXCEPTION return EXCEPTION
return VALID return VALID
def getDependentMessageList(self, activity_tool, message, **kw): def getDependentMessageList(self, activity_tool, message):
message_list = [] message_list = []
for k, v in kw.iteritems(): for k, v in message.activity_kw.iteritems():
result = activity_tool.getDependentMessageList(message, k, v) message_list += activity_tool.getDependentMessageList(message, k, v)
if result:
message_list.extend(result)
return message_list return message_list
def getExecutableMessageList(self, activity_tool, message, message_dict, def getExecutableMessageList(self, activity_tool, message, message_dict,
...@@ -174,7 +172,7 @@ class Queue(object): ...@@ -174,7 +172,7 @@ class Queue(object):
cached_result = validation_text_dict.get(message.order_validation_text) cached_result = validation_text_dict.get(message.order_validation_text)
if cached_result is None: if cached_result is None:
message_list = message.getDependentMessageList(self, activity_tool) message_list = self.getDependentMessageList(activity_tool, message)
transaction.commit() # Release locks. transaction.commit() # Release locks.
if message_list: if message_list:
# The result is not empty, so this message is not executable. # The result is not empty, so this message is not executable.
...@@ -197,8 +195,6 @@ class Queue(object): ...@@ -197,8 +195,6 @@ class Queue(object):
message_dict[message.uid] = message message_dict[message.uid] = message
elif cached_result: elif cached_result:
message_dict[message.uid] = message message_dict[message.uid] = message
else:
pass
def hasActivity(self, activity_tool, object, processing_node=None, active_process=None, **kw): def hasActivity(self, activity_tool, object, processing_node=None, active_process=None, **kw):
return 0 return 0
......
...@@ -308,9 +308,6 @@ class Message(BaseMessage): ...@@ -308,9 +308,6 @@ class Message(BaseMessage):
check_order_validation=check_order_validation, check_order_validation=check_order_validation,
**self.activity_kw) **self.activity_kw)
def getDependentMessageList(self, activity, activity_tool):
return activity.getDependentMessageList(activity_tool, self, **self.activity_kw)
def notifyUser(self, activity_tool, retry=False): def notifyUser(self, activity_tool, retry=False):
"""Notify the user that the activity failed.""" """Notify the user that the activity failed."""
portal = activity_tool.getPortalObject() portal = activity_tool.getPortalObject()
...@@ -1422,13 +1419,13 @@ class ActivityTool (Folder, UniqueObject): ...@@ -1422,13 +1419,13 @@ class ActivityTool (Folder, UniqueObject):
if not is_initialized: if not is_initialized:
self.initialize() self.initialize()
message_list = [] message_list = []
method_id = "_validate_%s" % validator_id method_id = "_validate_" + validator_id
for activity in activity_dict.itervalues(): for activity in activity_dict.itervalues():
method = getattr(activity, method_id, None) method = getattr(activity, method_id, None)
if method is not None: if method is not None:
result = method(aq_inner(self), message, validation_value) result = method(aq_inner(self), message, validation_value)
if result: if result:
message_list.extend([(activity, m) for m in result]) message_list += [(activity, m) for m in result]
return message_list return message_list
# Required for tests (time shift) # Required for tests (time shift)
......
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