Commit 458b5366 authored by Julien Muchembled's avatar Julien Muchembled

typos + code factoring

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32088 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7ecff2c2
......@@ -260,8 +260,7 @@ class SQLDict(RAMDict, SQLBase):
now_date = self.getNow(activity_tool)
message_list = []
def append(line, message):
uid = line.uid
message_list.append((uid, message, line.priority))
message_list.append((line.uid, message, line.priority))
count = 0
group_method_id = None
try:
......@@ -269,11 +268,13 @@ class SQLDict(RAMDict, SQLBase):
uid_to_duplicate_uid_list_dict = {}
if len(result) > 0:
line = result[0]
m = self.loadMessage(line.message, uid=line.uid)
uid = line.uid
m = self.loadMessage(line.message, uid=uid)
append(line, m)
group_method_id = line.group_method_id
activity_tool.SQLDict_processMessage(uid=[line.uid])
uid_to_duplicate_uid_list_dict.setdefault(line.uid, []).extend(getDuplicateMessageUidList(line))
activity_tool.SQLDict_processMessage(uid=[uid])
uid_to_duplicate_uid_list_dict.setdefault(uid, []) \
.extend(getDuplicateMessageUidList(line))
if group_method_id not in (None, '', '\0'):
# Count the number of objects to prevent too many objects.
count += len(m.getObjectList(activity_tool))
......@@ -448,11 +449,11 @@ class SQLDict(RAMDict, SQLBase):
'uid': message_uid_priority_list[0][0]})
setActivityRuntimeValue('processing_node', processing_node)
# Commit right before executing messages.
# As MySQL transaction do no start exactly at the same time as ZODB
# As MySQL transaction does not start exactly at the same time as ZODB
# transactions but a bit later, messages available might be called
# on objects which are not available - or available in an old
# version - to ZODB connector.
# So all connectors must be commited now that we have selected
# So all connectors must be committed now that we have selected
# everything needed from MySQL to get a fresh view of ZODB objects.
get_transaction().commit()
# Try to invoke
......
......@@ -294,11 +294,11 @@ class SQLQueue(RAMQueue, SQLBase):
processing_stop_time = time() + 30 # Stop processing after more than 10 seconds were spent
processed_message_uid_list = []
# Commit right before executing messages.
# As MySQL transaction do no start exactly at the same time as ZODB
# As MySQL transaction does not start exactly at the same time as ZODB
# transactions but a bit later, messages available might be called
# on objects which are not available - or available in an old
# version - to ZODB connector.
# So all connectors must be commited now that we have selected
# So all connectors must be committed now that we have selected
# everything needed from MySQL to get a fresh view of ZODB objects.
get_transaction().commit()
for value in message_uid_priority_list:
......
......@@ -56,6 +56,20 @@ try:
except ImportError:
pass
class CommitFailed(Exception):
pass
def registerFailingTransactionManager(*args, **kw):
from Shared.DC.ZRDB.TM import TM
class dummy_tm(TM):
def tpc_vote(self, *ignored):
raise CommitFailed
def _finish(self):
pass
def _abort(self):
pass
dummy_tm()._register()
class TestCMFActivity(ERP5TypeTestCase):
run_all_test = 1
......@@ -2525,18 +2539,6 @@ class TestCMFActivity(ERP5TypeTestCase):
self.tic()
activity_tool = self.getActivityTool()
from Shared.DC.ZRDB.TM import TM
class dummy_tm(TM):
def tpc_vote(self, *ignored):
raise Exception, 'vote always raises'
def _finish(self):
pass
def _abort(self):
pass
dummy_tm_instance = dummy_tm()
def registerFailingTransactionManager(self, *args, **kw):
dummy_tm_instance._register()
try:
Organisation.registerFailingTransactionManager = registerFailingTransactionManager
obj = self.getPortal().organisation_module.newContent(portal_type='Organisation')
......@@ -2581,19 +2583,6 @@ class TestCMFActivity(ERP5TypeTestCase):
get_transaction().commit()
self.tic()
activity_tool = self.getActivityTool()
from Shared.DC.ZRDB.TM import TM
class dummy_tm(TM):
def tpc_vote(self, *ignored):
raise Exception, 'vote always raises'
def _finish(self):
pass
def _abort(self):
pass
dummy_tm_instance = dummy_tm()
def registerFailingTransactionManager(self, *args, **kw):
dummy_tm_instance._register()
try:
Organisation.registerFailingTransactionManager = registerFailingTransactionManager
obj = self.getPortal().organisation_module.newContent(portal_type='Organisation')
......
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