Commit 38f22d65 authored by Leonardo Rochael Almeida's avatar Leonardo Rochael Almeida
Browse files

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