Commit fd7a2741 authored by Jérome Perrin's avatar Jérome Perrin

reactivate messages using their original activity queue when recreating

activity table ( manageClearActivities ). Messages where always reactivated
using SQLDict


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27487 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3a059080
......@@ -36,6 +36,7 @@ import re
from Products.CMFCore import CMFCorePermissions
from Products.ERP5Type.Core.Folder import Folder
from Products.CMFActivity.ActiveResult import ActiveResult
from Products.CMFActivity.ActiveObject import DEFAULT_ACTIVITY
from Products.PythonScripts.Utility import allow_class
from AccessControl import ClassSecurityInfo, Permissions
from AccessControl.SecurityManagement import newSecurityManager
......@@ -347,7 +348,7 @@ Exception: %s %s
except (socket.error, MailHostError), message:
LOG('ActivityTool.notifyUser', WARNING, 'Mail containing failure information failed to be sent: %s. Exception was: %s %s\n%s' % (message, self.exc_type, self.exc_value, self.traceback))
def reactivate(self, activity_tool):
def reactivate(self, activity_tool, activity=DEFAULT_ACTIVITY):
# Reactivate the original object.
obj= self.getObject(activity_tool)
# Change user if required (TO BE DONE)
......@@ -355,7 +356,7 @@ Exception: %s %s
current_user = str(_getAuthenticatedUser(self))
user = self.changeUser(self.user_name, activity_tool)
try:
active_obj = obj.activate(**self.activity_kw)
active_obj = obj.activate(activity=activity, **self.activity_kw)
getattr(active_obj, self.method_id)(*self.args, **self.kw)
finally:
# Use again the previous user
......@@ -1273,12 +1274,13 @@ class ActivityTool (Folder, UniqueObject):
folder = getToolByName(self, 'portal_skins').activity
# Obtain all pending messages.
message_list = []
message_list_dict = {}
if keep:
for activity in activity_dict.itervalues():
if hasattr(activity, 'dumpMessageList'):
try:
message_list.extend(activity.dumpMessageList(self))
message_list_dict[activity.__class__.__name__] =\
activity.dumpMessageList(self)
except ConflictError:
raise
except:
......@@ -1309,9 +1311,10 @@ class ActivityTool (Folder, UniqueObject):
folder.SQLQueue_createMessageTable()
# Reactivate the messages.
for activity, message_list in message_list_dict.iteritems():
for m in message_list:
try:
m.reactivate(aq_inner(self))
m.reactivate(aq_inner(self), activity=activity)
except ConflictError:
raise
except:
......
......@@ -630,7 +630,7 @@ class TestCMFActivity(ERP5TypeTestCase):
self.tic()
self.assertEquals(o.getTitle(), 'last')
def CheckClearActivities(self, activity):
def CheckClearActivities(self, activity, activity_count=1):
"""
Check if active objects are held even after clearing the tables.
"""
......@@ -643,12 +643,13 @@ class TestCMFActivity(ERP5TypeTestCase):
def check(o):
message_list = portal.portal_activities.getMessageList()
self.assertEquals(len(message_list), 1)
self.assertEquals(len(message_list), activity_count)
m = message_list[0]
self.assertEquals(m.object_path, o.getPhysicalPath())
self.assertEquals(m.method_id, '_setTitle')
o = portal.organisation._getOb(self.company_id)
for i in range(activity_count):
o.activate(activity=activity)._setTitle('foo')
get_transaction().commit()
check(o)
......@@ -1472,7 +1473,7 @@ class TestCMFActivity(ERP5TypeTestCase):
message = '\nCheck Clearing Activities With SQL Queue'
ZopeTestCase._print(message)
LOG('Testing... ',0,message)
self.CheckClearActivities('SQLQueue')
self.CheckClearActivities('SQLQueue', activity_count=2)
def flushAllActivities(self, silent=0, loop_size=1000):
"""Executes all messages until the queue only contains failed
......
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