replace transaction subcommits (deprecated since Zope 2.8 or before) with...

replace transaction subcommits (deprecated since Zope 2.8 or before) with optimistic savepoints, which do the same thing.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30370 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a45c35e3
...@@ -312,11 +312,11 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -312,11 +312,11 @@ class TestCMFActivity(ERP5TypeTestCase):
portal = self.getPortal() portal = self.getPortal()
def DeferredSetTitle(self,value,commit_sub=0): def DeferredSetTitle(self,value,commit_sub=0):
if commit_sub: if commit_sub:
get_transaction().commit(1) get_transaction().savepoint(optimistic=True)
self.activate(activity=second or activity,priority=4)._setTitle(value) self.activate(activity=second or activity,priority=4)._setTitle(value)
def DeferredSetDescription(self,value,commit_sub=0): def DeferredSetDescription(self,value,commit_sub=0):
if commit_sub: if commit_sub:
get_transaction().commit(1) get_transaction().savepoint(optimistic=True)
self.activate(activity=second or activity,priority=4)._setDescription(value) self.activate(activity=second or activity,priority=4)._setDescription(value)
from Products.ERP5Type.Document.Organisation import Organisation from Products.ERP5Type.Document.Organisation import Organisation
Organisation.DeferredSetTitle = DeferredSetTitle Organisation.DeferredSetTitle = DeferredSetTitle
......
...@@ -2,6 +2,7 @@ from Products.ERP5Type.Globals import get_request ...@@ -2,6 +2,7 @@ from Products.ERP5Type.Globals import get_request
from Acquisition import aq_base from Acquisition import aq_base
from Products.ERP5Type.Globals import PersistentMapping from Products.ERP5Type.Globals import PersistentMapping
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
import transaction
def fixProductNames(self, REQUEST=None): def fixProductNames(self, REQUEST=None):
...@@ -69,7 +70,7 @@ def updateBalanceTransactionClass(self): ...@@ -69,7 +70,7 @@ def updateBalanceTransactionClass(self):
obj = obj.getObject() obj = obj.getObject()
#print 'updating', obj, 'with class', BalanceTransaction #print 'updating', obj, 'with class', BalanceTransaction
changeObjectClass(module, obj.getId(), BalanceTransaction) changeObjectClass(module, obj.getId(), BalanceTransaction)
get_transaction().commit(1) transaction.savepoint(optimistic=True)
newobj = getattr(module, obj.getId()) newobj = getattr(module, obj.getId())
reverseSourceAndDestination(newobj) reverseSourceAndDestination(newobj)
......
# def this_transaction(): import transaction
# return get_transaction()
#
# def commit_transaction():
# get_transaction().commit()
def abort_transaction(): def abort_transaction():
get_transaction().abort() # FIXME: aborting a transaction means it could be commited later on. The
# transaction should be doom()ed instead, but transaction.doom() is not
# def abort_subtransaction(): # available on Zope 2.8. We should provide our own doom() implementation
# get_transaction().abort(1) # which raises an exception on pre-commit-hook, which does exist
# # in Zope 2.8
# def commit_subtransaction(): transaction.abort()
# get_transaction().commit(1)
...@@ -315,7 +315,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -315,7 +315,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
uids=uid_list, uids=uid_list,
md5_object_uid_list=md5_string) md5_object_uid_list=md5_string)
self.assert_('Deleted.' in redirect, redirect) self.assert_('Deleted.' in redirect, redirect)
transaction.commit(1) transaction.savepoint(optimistic=True)
self.assertEquals(len(module.objectValues()), 0) self.assertEquals(len(module.objectValues()), 0)
def test_Folder_delete_related_object(self): def test_Folder_delete_related_object(self):
...@@ -339,7 +339,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -339,7 +339,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
uids=uid_list, uids=uid_list,
md5_object_uid_list=md5_string) md5_object_uid_list=md5_string)
self.assert_('Sorry, 1 item is in use.' in redirect, redirect) self.assert_('Sorry, 1 item is in use.' in redirect, redirect)
transaction.commit(1) transaction.savepoint(optimistic=True)
self.assertEquals(len(module.objectValues()), 2) self.assertEquals(len(module.objectValues()), 2)
...@@ -368,7 +368,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -368,7 +368,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
uids=uid_list, uids=uid_list,
md5_object_uid_list=md5_string) md5_object_uid_list=md5_string)
self.assert_('Sorry, 1 item is in use.' in redirect, redirect) self.assert_('Sorry, 1 item is in use.' in redirect, redirect)
transaction.commit(1) transaction.savepoint(optimistic=True)
self.assertEquals(len(module.objectValues()), 2) self.assertEquals(len(module.objectValues()), 2)
......
...@@ -1026,7 +1026,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn, ...@@ -1026,7 +1026,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
update_list += method_message update_list += method_message
update_list += test_after(o,REQUEST=REQUEST) update_list += test_after(o,REQUEST=REQUEST)
# And commit subtransaction # And commit subtransaction
#transaction.commit(1) #transaction.savepoint(optimistic=True)
transaction.commit() # we may use commit(1) some day XXX transaction.commit() # we may use commit(1) some day XXX
# Recursively call recursiveApply if o has a recursiveApply method (not acquired) # Recursively call recursiveApply if o has a recursiveApply method (not acquired)
obase = aq_base(o) obase = aq_base(o)
...@@ -1262,7 +1262,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn, ...@@ -1262,7 +1262,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
btree_ok = self._cleanup() btree_ok = self._cleanup()
if not btree_ok: if not btree_ok:
# We must commit if we want to keep on recursing # We must commit if we want to keep on recursing
transaction.commit(1) transaction.savepoint(optimistic=True)
error_list += [(self.getRelativeUrl(), 'BTree Inconsistency', error_list += [(self.getRelativeUrl(), 'BTree Inconsistency',
199, '(fixed)')] 199, '(fixed)')]
# Call superclass # Call superclass
...@@ -1270,7 +1270,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn, ...@@ -1270,7 +1270,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
# We must commit before listing folder contents # We must commit before listing folder contents
# in case we erased some data # in case we erased some data
if fixit: if fixit:
transaction.commit(1) transaction.savepoint(optimistic=True)
# Then check the consistency on all sub objects # Then check the consistency on all sub objects
for obj in self.contentValues(): for obj in self.contentValues():
if fixit: if fixit:
......
...@@ -119,7 +119,7 @@ class TestCachedSkinsTool(ERP5TypeTestCase): ...@@ -119,7 +119,7 @@ class TestCachedSkinsTool(ERP5TypeTestCase):
tested_skin_folder.manage_addProduct['OFSP'].manage_addFolder(id=searched_object_id) tested_skin_folder.manage_addProduct['OFSP'].manage_addFolder(id=searched_object_id)
# Commit transaction so that the created object gets a _p_jar, so it can be renamed. # Commit transaction so that the created object gets a _p_jar, so it can be renamed.
# See OFS.CopySupport:CopySource.cb_isMoveable() # See OFS.CopySupport:CopySource.cb_isMoveable()
transaction.commit(1) transaction.savepoint(optimistic=True)
self.getSkinnableObject().changeSkin(skinname=None) self.getSkinnableObject().changeSkin(skinname=None)
# Access the object to make sure it is present in cache. # Access the object to make sure it is present in cache.
self.assertTrue(getattr(skinnable_object, searched_object_id, None) is not None) self.assertTrue(getattr(skinnable_object, searched_object_id, None) is not None)
......
...@@ -561,7 +561,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -561,7 +561,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
folder.newContent(portal_type='Organisation', id=id_) folder.newContent(portal_type='Organisation', id=id_)
# commit a subtransaction, so that we can rename objecs (see # commit a subtransaction, so that we can rename objecs (see
# OFS.ObjectManager._getCopy) # OFS.ObjectManager._getCopy)
transaction.commit(1) transaction.savepoint(optimistic=True)
for obj in folder.objectValues(): for obj in folder.objectValues():
new_id = '%s_new' % obj.getId() new_id = '%s_new' % obj.getId()
......
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