Commit 012d64a8 authored by Jérome Perrin's avatar Jérome Perrin

get_transaction -> transaction


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26982 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b4719e09
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import unittest import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -85,12 +86,12 @@ class TestGUISecurity(ERP5TypeTestCase): ...@@ -85,12 +86,12 @@ class TestGUISecurity(ERP5TypeTestCase):
asg.setStartDate(DateTime() - 100) asg.setStartDate(DateTime() - 100)
asg.setStopDate(DateTime() + 100) asg.setStopDate(DateTime() + 100)
asg.open() asg.open()
get_transaction().commit() transaction.commit()
def stepCreateTestFoo(self, sequence = None, sequence_list = None, **kw): def stepCreateTestFoo(self, sequence = None, sequence_list = None, **kw):
foo_module = self.getPortal().foo_module foo_module = self.getPortal().foo_module
foo_module.newContent(portal_type='Foo', id='foo', foo_category='a') foo_module.newContent(portal_type='Foo', id='foo', foo_category='a')
get_transaction().commit() transaction.commit()
def stepAccessFoo(self, sequence = None, sequence_list = None, **kw): def stepAccessFoo(self, sequence = None, sequence_list = None, **kw):
""" """
...@@ -109,7 +110,7 @@ class TestGUISecurity(ERP5TypeTestCase): ...@@ -109,7 +110,7 @@ class TestGUISecurity(ERP5TypeTestCase):
args = (('Manager',), 0) args = (('Manager',), 0)
category.manage_permission('Access contents information', *args) category.manage_permission('Access contents information', *args)
category.manage_permission('View', *args) category.manage_permission('View', *args)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
def stepResetCategorySecurity(self, sequence = None, sequence_list = None, **kw): def stepResetCategorySecurity(self, sequence = None, sequence_list = None, **kw):
...@@ -120,7 +121,7 @@ class TestGUISecurity(ERP5TypeTestCase): ...@@ -120,7 +121,7 @@ class TestGUISecurity(ERP5TypeTestCase):
args = ((), 1) args = ((), 1)
category.manage_permission('Access contents information', *args) category.manage_permission('Access contents information', *args)
category.manage_permission('View', *args) category.manage_permission('View', *args)
get_transaction().commit() transaction.commit()
self.tic() self.tic()
def test_01_relationFieldToInaccessibleObject(self, quiet=quiet, run=run_all_test): def test_01_relationFieldToInaccessibleObject(self, quiet=quiet, run=run_all_test):
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import unittest import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG from zLOG import LOG
...@@ -258,7 +259,7 @@ return [] ...@@ -258,7 +259,7 @@ return []
request.form['my_file_upload'] = FileUpload(DummyFieldStorage()) request.form['my_file_upload'] = FileUpload(DummyFieldStorage())
listbox.get_value('default', render_format='list', REQUEST=request) listbox.get_value('default', render_format='list', REQUEST=request)
try: try:
get_transaction().commit() transaction.commit()
except TypeError, e: except TypeError, e:
self.fail('Unable to commit transaction: %s' % e) self.fail('Unable to commit transaction: %s' % e)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
############################################################################## ##############################################################################
import unittest import unittest
import transaction
from Products.ERP5Form.Form import ERP5Form from Products.ERP5Form.Form import ERP5Form
from DocumentTemplate import String from DocumentTemplate import String
...@@ -99,7 +100,7 @@ class TestOOoChart(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -99,7 +100,7 @@ class TestOOoChart(ERP5TypeTestCase, ZopeTestCase.Functional):
wf_id='preference_workflow') wf_id='preference_workflow')
self.validator = Validator() self.validator = Validator()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
def createPersons(self): def createPersons(self):
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import unittest import unittest
import transaction
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
...@@ -57,7 +58,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -57,7 +58,7 @@ class TestPreferences(ERP5TypeTestCase):
def beforeTearDown(self): def beforeTearDown(self):
portal_preferences = self.getPreferenceTool() portal_preferences = self.getPreferenceTool()
portal_preferences.manage_delObjects(list(portal_preferences.objectIds())) portal_preferences.manage_delObjects(list(portal_preferences.objectIds()))
get_transaction().commit() transaction.commit()
self.tic() self.tic()
def createPreferences(self) : def createPreferences(self) :
...@@ -76,7 +77,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -76,7 +77,7 @@ class TestPreferences(ERP5TypeTestCase):
site.setPriority(Priority.SITE) site.setPriority(Priority.SITE)
# commit transaction # commit transaction
get_transaction().commit() transaction.commit()
self.getPreferenceTool().recursiveReindexObject() self.getPreferenceTool().recursiveReindexObject()
self.tic() self.tic()
...@@ -299,7 +300,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -299,7 +300,7 @@ class TestPreferences(ERP5TypeTestCase):
id='user_a_1', portal_type='Preference') id='user_a_1', portal_type='Preference')
user_a_2 = portal_preferences.newContent( user_a_2 = portal_preferences.newContent(
id='user_a_2', portal_type='Preference') id='user_a_2', portal_type='Preference')
get_transaction().commit(); self.tic() transaction.commit(); self.tic()
# enable a pref # enable a pref
portal_workflow.doActionFor( portal_workflow.doActionFor(
...@@ -314,7 +315,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -314,7 +315,7 @@ class TestPreferences(ERP5TypeTestCase):
user_b_1 = portal_preferences.newContent( user_b_1 = portal_preferences.newContent(
id='user_b_1', portal_type='Preference') id='user_b_1', portal_type='Preference')
user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 02, 02)) user_b_1.setPreferredAccountingTransactionAtDate(DateTime(2002, 02, 02))
get_transaction().commit(); self.tic() transaction.commit(); self.tic()
# enable this preference # enable this preference
portal_workflow.doActionFor( portal_workflow.doActionFor(
...@@ -338,7 +339,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -338,7 +339,7 @@ class TestPreferences(ERP5TypeTestCase):
id='manager_pref', portal_type='Preference') id='manager_pref', portal_type='Preference')
manager_pref.setPreferredAccountingTransactionAtDate( manager_pref.setPreferredAccountingTransactionAtDate(
DateTime(2012, 12, 12)) DateTime(2012, 12, 12))
get_transaction().commit(); self.tic() transaction.commit(); self.tic()
# enable this preference # enable this preference
portal_workflow.doActionFor( portal_workflow.doActionFor(
manager_pref, 'enable_action', wf_id='preference_workflow') manager_pref, 'enable_action', wf_id='preference_workflow')
...@@ -357,7 +358,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -357,7 +358,7 @@ class TestPreferences(ERP5TypeTestCase):
self.getPortal().portal_workflow.doActionFor( self.getPortal().portal_workflow.doActionFor(
ptool.site, 'enable_action', wf_id='preference_workflow') ptool.site, 'enable_action', wf_id='preference_workflow')
self.assertEquals('global', ptool.site.getPreferenceState()) self.assertEquals('global', ptool.site.getPreferenceState())
get_transaction().commit() transaction.commit()
self.tic() self.tic()
noSecurityManager() noSecurityManager()
self.assertEquals(['this_is_visible_by_anonymous'], self.assertEquals(['this_is_visible_by_anonymous'],
...@@ -441,7 +442,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -441,7 +442,7 @@ class TestPreferences(ERP5TypeTestCase):
# enable it and check preference is returned # enable it and check preference is returned
self.portal.portal_workflow.doActionFor(site_pref, 'enable_action') self.portal.portal_workflow.doActionFor(site_pref, 'enable_action')
self.assertEquals(site_pref.getPreferenceState(), 'global') self.assertEquals(site_pref.getPreferenceState(), 'global')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
self.assertEquals(['this_is_default'], self.assertEquals(['this_is_default'],
preference_tool.getPreferredAccountingTransactionSimulationStateList()) preference_tool.getPreferredAccountingTransactionSimulationStateList())
...@@ -457,7 +458,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -457,7 +458,7 @@ class TestPreferences(ERP5TypeTestCase):
# check accessors works # check accessors works
site_pref.setPreferredAccountingTransactionSimulationStateList( site_pref.setPreferredAccountingTransactionSimulationStateList(
['this_is_system']) ['this_is_system'])
get_transaction().commit() transaction.commit()
self.tic() self.tic()
self.assertEquals(['this_is_system'], self.assertEquals(['this_is_system'],
preference_tool.getPreferredAccountingTransactionSimulationStateList()) preference_tool.getPreferredAccountingTransactionSimulationStateList())
...@@ -471,7 +472,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -471,7 +472,7 @@ class TestPreferences(ERP5TypeTestCase):
['this_is_user']) ['this_is_user'])
self.portal.portal_workflow.doActionFor(user_pref, 'enable_action') self.portal.portal_workflow.doActionFor(user_pref, 'enable_action')
self.assertEquals(user_pref.getPreferenceState(), 'enabled') self.assertEquals(user_pref.getPreferenceState(), 'enabled')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
self.assertEquals(['this_is_user'], self.assertEquals(['this_is_user'],
user_pref.getPreferredAccountingTransactionSimulationStateList()) user_pref.getPreferredAccountingTransactionSimulationStateList())
...@@ -481,7 +482,7 @@ class TestPreferences(ERP5TypeTestCase): ...@@ -481,7 +482,7 @@ class TestPreferences(ERP5TypeTestCase):
# check a user can't edit preference which are marked for manager (only for zope2.8) # check a user can't edit preference which are marked for manager (only for zope2.8)
try: try:
from ZODB.Transaction import Transaction from ZODB.Transaction import Transaction
except ImportError: except ImportError:
self.assertRaises(Unauthorized, user_pref.edit, preferred_ooodoc_server_address="localhost") self.assertRaises(Unauthorized, user_pref.edit, preferred_ooodoc_server_address="localhost")
......
...@@ -30,6 +30,7 @@ import unittest ...@@ -30,6 +30,7 @@ import unittest
from threading import Thread from threading import Thread
from thread import get_ident from thread import get_ident
import transaction
from Testing import ZODButil from Testing import ZODButil
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
...@@ -243,7 +244,7 @@ class TestSelectionPersistence(unittest.TestCase): ...@@ -243,7 +244,7 @@ class TestSelectionPersistence(unittest.TestCase):
self.portal_selections = \ self.portal_selections = \
self.cnx.root().portal_selections = SelectionTool() self.cnx.root().portal_selections = SelectionTool()
self.portal_selections.setSelectionFor('test_selection', Selection()) self.portal_selections.setSelectionFor('test_selection', Selection())
get_transaction().commit() transaction.commit()
def tearDown(self): def tearDown(self):
# revert the patch from setUp # revert the patch from setUp
...@@ -271,13 +272,13 @@ class TestSelectionPersistence(unittest.TestCase): ...@@ -271,13 +272,13 @@ class TestSelectionPersistence(unittest.TestCase):
portal_selections = cnx.root().portal_selections portal_selections = cnx.root().portal_selections
portal_selections.setSelectionParamsFor( portal_selections.setSelectionParamsFor(
'test_selection', dict(a="c")) 'test_selection', dict(a="c"))
get_transaction().commit() transaction.commit()
finally: finally:
cnx.close() cnx.close()
self._runWithAnotherConnection(thread_func) self._runWithAnotherConnection(thread_func)
# This would raise a ConflictError without conflict resolution code # This would raise a ConflictError without conflict resolution code
get_transaction().commit() transaction.commit()
params = self.portal_selections.getSelectionParamsFor('test_selection') params = self.portal_selections.getSelectionParamsFor('test_selection')
self.assertTrue(params.get('a')) self.assertTrue(params.get('a'))
...@@ -290,13 +291,13 @@ class TestSelectionPersistence(unittest.TestCase): ...@@ -290,13 +291,13 @@ class TestSelectionPersistence(unittest.TestCase):
portal_selections = cnx.root().portal_selections portal_selections = cnx.root().portal_selections
portal_selections.setSelectionParamsFor( portal_selections.setSelectionParamsFor(
'test_selection1', dict(a="b")) 'test_selection1', dict(a="b"))
get_transaction().commit() transaction.commit()
finally: finally:
cnx.close() cnx.close()
self._runWithAnotherConnection(thread_func) self._runWithAnotherConnection(thread_func)
# This would raise a ConflictError without conflict resolution code # This would raise a ConflictError without conflict resolution code
get_transaction().commit() transaction.commit()
params = self.portal_selections.getSelectionParamsFor('test_selection1') params = self.portal_selections.getSelectionParamsFor('test_selection1')
self.assertEquals(params.get('a'), 'b') self.assertEquals(params.get('a'), 'b')
params = self.portal_selections.getSelectionParamsFor('test_selection2') params = self.portal_selections.getSelectionParamsFor('test_selection2')
...@@ -313,7 +314,7 @@ class TestSelectionPersistence(unittest.TestCase): ...@@ -313,7 +314,7 @@ class TestSelectionPersistence(unittest.TestCase):
# So we make sure that selection container is initialized for this user # So we make sure that selection container is initialized for this user
self.portal_selections.setSelectionParamsFor( self.portal_selections.setSelectionParamsFor(
'test_selection', dict(initialized="1")) 'test_selection', dict(initialized="1"))
get_transaction().commit() transaction.commit()
self.portal_selections.setSelectionParamsFor( self.portal_selections.setSelectionParamsFor(
'test_selection', dict(a="b")) 'test_selection', dict(a="b"))
...@@ -322,12 +323,12 @@ class TestSelectionPersistence(unittest.TestCase): ...@@ -322,12 +323,12 @@ class TestSelectionPersistence(unittest.TestCase):
portal_selections = cnx.root().portal_selections portal_selections = cnx.root().portal_selections
portal_selections.setSelectionParamsFor( portal_selections.setSelectionParamsFor(
'test_selection', dict(a="b")) 'test_selection', dict(a="b"))
get_transaction().commit() transaction.commit()
finally: finally:
cnx.close() cnx.close()
self._runWithAnotherConnection(thread_func) self._runWithAnotherConnection(thread_func)
get_transaction().commit() transaction.commit()
# this check is quite low level. # this check is quite low level.
# we know that setUp stored one selection, and each of our 2 threads stored # we know that setUp stored one selection, and each of our 2 threads stored
# one selection. # one selection.
...@@ -337,7 +338,7 @@ class TestSelectionPersistence(unittest.TestCase): ...@@ -337,7 +338,7 @@ class TestSelectionPersistence(unittest.TestCase):
# test that selection parameters are persistent # test that selection parameters are persistent
self.portal_selections.setSelectionParamsFor( self.portal_selections.setSelectionParamsFor(
'test_selection', dict(key="saved_value")) 'test_selection', dict(key="saved_value"))
get_transaction().commit() transaction.commit()
self.cnx.close() self.cnx.close()
self.cnx = self.db.open() self.cnx = self.db.open()
......
...@@ -63,7 +63,7 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -63,7 +63,7 @@ class TestUserManagement(ERP5TypeTestCase):
clearCache(cache_factory_list=('erp5_content_short', )) clearCache(cache_factory_list=('erp5_content_short', ))
self.getPersonModule().manage_delObjects([x for x in self.getPersonModule().manage_delObjects([x for x in
self.getPersonModule().objectIds()]) self.getPersonModule().objectIds()])
get_transaction().commit() transaction.commit()
self.tic() self.tic()
def login(self): def login(self):
...@@ -114,7 +114,7 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -114,7 +114,7 @@ class TestUserManagement(ERP5TypeTestCase):
stop_date=assignment_stop_date,) stop_date=assignment_stop_date,)
if open_assignment: if open_assignment:
assignment.open() assignment.open()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
return new_person return new_person
...@@ -350,7 +350,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -350,7 +350,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
site='subcat', site='subcat',
function='subcat' ) function='subcat' )
assignment.open() assignment.open()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
def beforeTearDown(self): def beforeTearDown(self):
...@@ -366,7 +366,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -366,7 +366,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
for module in self.portal.objectValues(spec=('ERP5 Folder',)): for module in self.portal.objectValues(spec=('ERP5 Folder',)):
module.manage_delObjects([x for x in module.objectIds()]) module.manage_delObjects([x for x in module.objectIds()])
# commit this # commit this
get_transaction().commit() transaction.commit()
self.tic() self.tic()
# XXX Isn't it better to clear the cache when deleting a Person ? # XXX Isn't it better to clear the cache when deleting a Person ?
clearCache(cache_factory_list=('erp5_content_short', )) clearCache(cache_factory_list=('erp5_content_short', ))
...@@ -475,21 +475,21 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -475,21 +475,21 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
# getUserByLogin accept login as a string # getUserByLogin accept login as a string
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
get_transaction().commit() transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin(self.username) person_list = self.portal.acl_users.erp5_users.getUserByLogin(self.username)
self.assertEquals(1, len(person_list)) self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference()) self.assertEquals(self.username, person_list[0].getReference())
# getUserByLogin accept login as a list # getUserByLogin accept login as a list
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
get_transaction().commit() transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin([self.username]) person_list = self.portal.acl_users.erp5_users.getUserByLogin([self.username])
self.assertEquals(1, len(person_list)) self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference()) self.assertEquals(self.username, person_list[0].getReference())
# getUserByLogin accept login as a tuple # getUserByLogin accept login as a tuple
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
get_transaction().commit() transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin((self.username,)) person_list = self.portal.acl_users.erp5_users.getUserByLogin((self.username,))
self.assertEquals(1, len(person_list)) self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference()) self.assertEquals(self.username, person_list[0].getReference())
...@@ -497,7 +497,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -497,7 +497,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
# PreferenceTool pass a user as parameter # PreferenceTool pass a user as parameter
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
get_transaction().commit() transaction.commit()
person_list = self.portal.acl_users.erp5_users.getUserByLogin(user) person_list = self.portal.acl_users.erp5_users.getUserByLogin(user)
self.assertEquals(1, len(person_list)) self.assertEquals(1, len(person_list))
self.assertEquals(self.username, person_list[0].getReference()) self.assertEquals(self.username, person_list[0].getReference())
...@@ -517,7 +517,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -517,7 +517,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
assignment = loginable_person.newContent(portal_type='Assignment', assignment = loginable_person.newContent(portal_type='Assignment',
function='another_subcat') function='another_subcat')
assignment.open() assignment.open()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
person_module_type_information = self.getTypesTool()['Person Module'] person_module_type_information = self.getTypesTool()['Person Module']
...@@ -530,7 +530,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -530,7 +530,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
base_category_script='', base_category_script='',
base_category='') base_category='')
person_module_type_information.updateRoleMapping() person_module_type_information.updateRoleMapping()
get_transaction().commit() transaction.commit()
self.tic() self.tic()
person_module_path = self.getPersonModule().absolute_url(relative=1) person_module_path = self.getPersonModule().absolute_url(relative=1)
...@@ -547,7 +547,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -547,7 +547,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
self.getOrganisationModule().newContent(portal_type='Organisation', self.getOrganisationModule().newContent(portal_type='Organisation',
id='my_company', id='my_company',
title='Nexedi') title='Nexedi')
get_transaction().commit() transaction.commit()
self.tic() self.tic()
response = self.publish('/%s/my_company/getTitle' % self.getOrganisationModule().absolute_url(relative=1), response = self.publish('/%s/my_company/getTitle' % self.getOrganisationModule().absolute_url(relative=1),
basic='guest:guest') basic='guest:guest')
......
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