Commit 1835e1b8 authored by Sebastien Robin's avatar Sebastien Robin

corrected some bugs when we want to invoke messages by hand


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@695 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9d8505db
...@@ -190,4 +190,7 @@ class Queue: ...@@ -190,4 +190,7 @@ class Queue:
def getRegisteredMessageList(self, activity_buffer, activity_tool): def getRegisteredMessageList(self, activity_buffer, activity_tool):
class_name = self.__class__.__name__ class_name = self.__class__.__name__
if hasattr(activity_buffer, '_%s_message_list' % class_name):
return filter(lambda m: m.is_registered, getattr(activity_buffer, '_%s_message_list' % class_name)) return filter(lambda m: m.is_registered, getattr(activity_buffer, '_%s_message_list' % class_name))
else:
return ()
...@@ -86,7 +86,10 @@ class SQLDict(RAMDict): ...@@ -86,7 +86,10 @@ class SQLDict(RAMDict):
del activity_buffer._sqldict_uid_dict[(m.object_path, m.method_id)] del activity_buffer._sqldict_uid_dict[(m.object_path, m.method_id)]
def getRegisteredMessageList(self, activity_buffer, activity_tool): def getRegisteredMessageList(self, activity_buffer, activity_tool):
if hasattr(activity_buffer,'_sqldict_message_list'):
return filter(lambda m: m.is_registered, activity_buffer._sqldict_message_list) return filter(lambda m: m.is_registered, activity_buffer._sqldict_message_list)
else:
return ()
# Queue semantic # Queue semantic
def dequeueMessage(self, activity_tool, processing_node): def dequeueMessage(self, activity_tool, processing_node):
......
...@@ -105,8 +105,7 @@ class Message: ...@@ -105,8 +105,7 @@ class Message:
# Store REQUEST Info ? # Store REQUEST Info ?
def __call__(self, activity_tool): def __call__(self, activity_tool):
#try: try:
if 1:
LOG('WARNING ActivityTool', 0, LOG('WARNING ActivityTool', 0,
'Trying to call method %s on object %s' % (self.method_id, self.object_path)) 'Trying to call method %s on object %s' % (self.method_id, self.object_path))
object = activity_tool.unrestrictedTraverse(self.object_path) object = activity_tool.unrestrictedTraverse(self.object_path)
...@@ -118,8 +117,7 @@ class Message: ...@@ -118,8 +117,7 @@ class Message:
active_process = activity_tool.getActiveProcess() active_process = activity_tool.getActiveProcess()
active_process.activateResult(Result(object,self.method_id,result)) # XXX Allow other method_id in future active_process.activateResult(Result(object,self.method_id,result)) # XXX Allow other method_id in future
self.is_executed = 1 self.is_executed = 1
else: except:
#except:
self.is_executed = 0 self.is_executed = 0
LOG('WARNING ActivityTool', 0, LOG('WARNING ActivityTool', 0,
'Could not call method %s on object %s' % (self.method_id, self.object_path)) 'Could not call method %s on object %s' % (self.method_id, self.object_path))
...@@ -234,11 +232,9 @@ class ActivityTool (Folder, UniqueObject): ...@@ -234,11 +232,9 @@ class ActivityTool (Folder, UniqueObject):
# Call distribute on each queue # Call distribute on each queue
for activity in activity_list: for activity in activity_list:
#try: try:
if 1:
activity.distribute(self, node_count) activity.distribute(self, node_count)
#except: except:
else:
LOG('CMFActivity:', 100, 'Core call to distribute failed for activity %s' % activity) LOG('CMFActivity:', 100, 'Core call to distribute failed for activity %s' % activity)
security.declarePublic('tic') security.declarePublic('tic')
...@@ -316,7 +312,10 @@ class ActivityTool (Folder, UniqueObject): ...@@ -316,7 +312,10 @@ class ActivityTool (Folder, UniqueObject):
self._v_activity_buffer.deferredDeleteMessage(self, activity, message) self._v_activity_buffer.deferredDeleteMessage(self, activity, message)
def getRegisteredMessageList(self, activity): def getRegisteredMessageList(self, activity):
if getattr(self, '_v_activity_buffer', None):
return activity.getRegisteredMessageList(self._v_activity_buffer, self) return activity.getRegisteredMessageList(self._v_activity_buffer, self)
else:
return []
def unregisterMessage(self, activity, message): def unregisterMessage(self, activity, message):
return activity.unregisterMessage(self._v_activity_buffer, self, message) return activity.unregisterMessage(self._v_activity_buffer, self, message)
...@@ -324,6 +323,10 @@ class ActivityTool (Folder, UniqueObject): ...@@ -324,6 +323,10 @@ class ActivityTool (Folder, UniqueObject):
def flush(self, object, invoke=0, **kw): def flush(self, object, invoke=0, **kw):
global is_initialized global is_initialized
if not is_initialized: self.initialize() if not is_initialized: self.initialize()
if not hasattr(self, '_v_activity_buffer'): self._v_activity_buffer = ActivityBuffer()
if type(object) is type(()):
object_path = object
else:
object_path = object.getPhysicalPath() object_path = object.getPhysicalPath()
for activity in activity_list: for activity in activity_list:
LOG('CMFActivity: ', 0, 'flushing activity %s' % activity.__class__.__name__) LOG('CMFActivity: ', 0, 'flushing activity %s' % activity.__class__.__name__)
...@@ -358,11 +361,7 @@ class ActivityTool (Folder, UniqueObject): ...@@ -358,11 +361,7 @@ class ActivityTool (Folder, UniqueObject):
""" """
if type(object_path) is type(''): if type(object_path) is type(''):
object_path = tuple(object_path.split('/')) object_path = tuple(object_path.split('/'))
for activity in activity_list: self.flush(object_path,method_id=method_id,invoke=1)
try:
activity.flush(self, object_path, method_id=method_id, invoke=1)
except AttributeError:
LOG('CMFActivity.manageCancel, Warning, could not flush activity on:',0,activity)
if REQUEST is not None: if REQUEST is not None:
return REQUEST.RESPONSE.redirect('%s/%s' % (self.absolute_url(), 'manageActivities')) return REQUEST.RESPONSE.redirect('%s/%s' % (self.absolute_url(), 'manageActivities'))
...@@ -372,11 +371,7 @@ class ActivityTool (Folder, UniqueObject): ...@@ -372,11 +371,7 @@ class ActivityTool (Folder, UniqueObject):
""" """
if type(object_path) is type(''): if type(object_path) is type(''):
object_path = tuple(object_path.split('/')) object_path = tuple(object_path.split('/'))
for activity in activity_list: self.flush(object_path,method_id=method_id,invoke=0)
try:
activity.flush(self, object_path, method_id=method_id, invoke=0)
except AttributeError:
LOG('CMFActivity.manageCancel, Warning, could not flush activity on:',0,activity)
if REQUEST is not None: if REQUEST is not None:
return REQUEST.RESPONSE.redirect('%s/%s' % (self.absolute_url(), 'manageActivities')) return REQUEST.RESPONSE.redirect('%s/%s' % (self.absolute_url(), 'manageActivities'))
......
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