Commit 12ee7004 authored by Jérome Perrin's avatar Jérome Perrin

get_transaction -> transaction


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26978 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent caf0097a
......@@ -50,6 +50,7 @@
import unittest
import time
import transaction
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload
......@@ -141,12 +142,12 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
"""
Remove everything after each run
"""
get_transaction().abort()
transaction.abort()
self.tic()
doc_module = self.getDocumentModule()
ids = [i for i in doc_module.objectIds()]
doc_module.manage_delObjects(ids)
get_transaction().commit()
transaction.commit()
self.tic()
## helper methods
......@@ -216,22 +217,22 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
file = makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file)
document.immediateReindexObject()
get_transaction().commit()
transaction.commit()
self.tic()
document_url = document.getRelativeUrl()
def getTestDocument():
return self.portal.restrictedTraverse(document_url)
self.failUnless(getTestDocument().getRevision() == '0')
getTestDocument().edit(file=file)
get_transaction().commit()
transaction.commit()
self.tic()
self.failUnless(getTestDocument().getRevision() == '1')
getTestDocument().edit(title='Hey Joe')
get_transaction().commit()
transaction.commit()
self.tic()
self.failUnless(getTestDocument().getRevision() == '2')
another_document = self.portal.portal_contributions.newContent(file=file)
get_transaction().commit()
transaction.commit()
self.tic()
self.failUnless(getTestDocument().getRevision() == '3')
self.failUnless(getTestDocument().getRevisionList() == ['0', '1', '2'] )
......@@ -256,13 +257,13 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
docs[2] = self.createTestDocument(reference='TEST', version='002', language='en')
docs[3] = self.createTestDocument(reference='TEST', version='004', language='en')
docs[4] = self.createTestDocument(reference='ANOTHER', version='002', language='en')
get_transaction().commit()
transaction.commit()
self.tic()
self.failIf(docs[1].isVersionUnique())
self.failIf(docs[2].isVersionUnique())
self.failUnless(docs[3].isVersionUnique())
docs[2].setVersion('003')
get_transaction().commit()
transaction.commit()
self.tic()
self.failUnless(docs[1].isVersionUnique())
self.failUnless(docs[2].isVersionUnique())
......@@ -312,7 +313,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
time.sleep(1)
docs[5] = self.createTestDocument(reference='TEST', version='003', language='sp')
time.sleep(1)
get_transaction().commit()
transaction.commit()
self.tic()
doc = docs[2] # can be any
self.failUnless(doc.getOriginalLanguage() == 'en')
......@@ -326,7 +327,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
self.failUnless(doc.getLatestVersionValue() == docs[5]) # there are two latest - it chooses the one in user language
docs[6] = document_module.newContent(reference='TEST', version='004', language='pl')
docs[7] = document_module.newContent(reference='TEST', version='004', language='en')
get_transaction().commit()
transaction.commit()
self.tic()
self.failUnless(doc.getLatestVersionValue() == docs[7]) # there are two latest, neither in user language - it chooses the one in original language
......@@ -383,7 +384,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
document7.setSimilarValue([document9])
document11.setSimilarValue(document7)
get_transaction().commit()
transaction.commit()
self.tic()
#if user language is 'en'
......@@ -409,7 +410,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertSameSet([document6, document7],
document13.getSimilarCloudValueList())
get_transaction().commit()
transaction.commit()
# if user language is 'fr', test that latest documents are prefferable returned in user_language (if available)
self.portal.Localizer.changeLanguage('fr')
......@@ -425,7 +426,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertSameSet([document6, document8],
document13.getSimilarCloudValueList())
get_transaction().commit()
transaction.commit()
# if user language is "bg"
self.portal.Localizer.changeLanguage('bg')
......@@ -485,7 +486,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
file = makeFileUpload(filename)
document8 = self.portal.portal_contributions.newContent(file=file)
get_transaction().commit()
transaction.commit()
self.tic()
printAndLog('\nTesting Implicit Predecessors')
# the implicit predecessor will find documents by reference.
......@@ -500,7 +501,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
sqlresult_to_document_list(document1.getImplicitPredecessorValueList()))
# clear transactional variable cache
get_transaction().commit()
transaction.commit()
printAndLog('\nTesting Implicit Successors')
# the implicit successors should be return document with appropriate
......@@ -514,7 +515,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
sqlresult_to_document_list(document5.getImplicitSuccessorValueList()))
# clear transactional variable cache
get_transaction().commit()
transaction.commit()
# if user language is 'fr'.
self.portal.Localizer.changeLanguage('fr')
......@@ -523,7 +524,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
sqlresult_to_document_list(document5.getImplicitSuccessorValueList()))
# clear transactional variable cache
get_transaction().commit()
transaction.commit()
# if user language is 'ja'.
self.portal.Localizer.changeLanguage('ja')
......@@ -590,9 +591,9 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
portal_type='Spreadsheet')
doc.edit(file=makeFileUpload('import_data_list.ods'))
doc.publish()
get_transaction().commit()
transaction.commit()
self.tic()
get_transaction().commit()
transaction.commit()
uf = self.portal.acl_users
uf._doAddUser('member_user2', 'secret', ['Member'], [])
......@@ -640,7 +641,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
document = self.portal.portal_contributions.newContent(file=file)
self.assertEquals('converting', document.getExternalProcessingState())
get_transaction().commit()
transaction.commit()
self.assertEquals('converting', document.getExternalProcessingState())
# Clone a uploaded document
......@@ -650,7 +651,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
new_document = container[paste_result[0]['new_id']]
self.assertEquals('converting', new_document.getExternalProcessingState())
get_transaction().commit()
transaction.commit()
self.assertEquals('converting', new_document.getExternalProcessingState())
# Change workflow state to converted
......@@ -665,7 +666,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
new_document = container[paste_result[0]['new_id']]
self.assertEquals('converted', new_document.getExternalProcessingState())
get_transaction().commit()
transaction.commit()
self.assertEquals('converted', new_document.getExternalProcessingState())
self.tic()
self.assertEquals('converted', new_document.getExternalProcessingState())
......@@ -683,7 +684,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
sub_document = document.newContent(portal_type='Image')
self.assertEquals('embedded', sub_document.getValidationState())
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals('embedded', sub_document.getValidationState())
......@@ -698,7 +699,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEquals(1, len(new_sub_document_list))
new_sub_document = new_sub_document_list[0]
self.assertEquals('embedded', new_sub_document.getValidationState())
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals('embedded', new_sub_document.getValidationState())
......@@ -712,7 +713,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
file = makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file)
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals(0, len(document.contentValues(portal_type='Image')))
......@@ -740,7 +741,7 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
document_2 = self.portal.document_module.newContent(portal_type='File')
document_2.setDescription('This test make sure that scriptable key feature on ZSQLCatalog works.')
get_transaction().commit()
transaction.commit()
self.tic()
# Use scriptable key to search above documents.
......@@ -784,7 +785,7 @@ class TestDocumentWithSecurity(ERP5TypeTestCase):
default_pref.setPreferredDocumentFileNameRegularExpression(FILE_NAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
default_pref.enable()
get_transaction().commit()
transaction.commit()
self.tic()
def login(self):
......@@ -810,14 +811,14 @@ class TestDocumentWithSecurity(ERP5TypeTestCase):
upload_file = makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=upload_file)
get_transaction().commit()
transaction.commit()
self.tic()
document.submit()
preview_html = document.Document_getPreviewAsHTML().replace('\n', ' ')
get_transaction().commit()
transaction.commit()
self.tic()
self.assert_('I use reference to look up TEST' in preview_html)
......
......@@ -28,6 +28,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
from AccessControl.SecurityManagement import newSecurityManager
......@@ -104,7 +105,7 @@ class TestFormPrintout(ERP5TypeTestCase):
test1.newContent("foo_1", portal_type='Foo Line')
if test1._getOb("foo_2", None) is None:
test1.newContent("foo_2", portal_type='Foo Line')
get_transaction().commit()
transaction.commit()
self.tic()
# XML validator
......@@ -135,7 +136,7 @@ class TestFormPrintout(ERP5TypeTestCase):
foo_module.newContent(id='test1', portal_type='Foo')
test1 = foo_module.test1
test1.setTitle('Foo title!')
get_transaction().commit()
transaction.commit()
self.tic()
# test target
......
......@@ -32,6 +32,7 @@
import unittest
import os, cStringIO, zipfile
from xml.dom.minidom import parseString
import transaction
from Testing import ZopeTestCase
from DateTime import DateTime
from AccessControl.SecurityManagement import newSecurityManager
......@@ -224,7 +225,7 @@ class TestIngestion(ERP5TypeTestCase):
if hasattr(new_category, method_id):
method = getattr(new_category, method_id)
method(value.encode('UTF-8'))
get_transaction().commit()
transaction.commit()
self.tic()
def getCategoryList(self, base_category=None):
......@@ -274,7 +275,7 @@ class TestIngestion(ERP5TypeTestCase):
document_module.manage_delObjects([id,])
document = document_module.newContent(portal_type=portal_type, id=id)
document.reindexObject()
get_transaction().commit()
transaction.commit()
self.tic()
self.checkIsObjectCatalogged(portal_type, id=id, parent_uid=document_module.getUid())
self.assert_(hasattr(document_module, id))
......@@ -304,7 +305,7 @@ class TestIngestion(ERP5TypeTestCase):
context.edit(file=f)
context.convertToBaseFormat()
context.reindexObject()
get_transaction().commit()
transaction.commit()
self.tic()
self.failUnless(context.hasFile())
if context.getPortalType() in ('Image', 'File', 'PDF'):
......@@ -328,7 +329,7 @@ class TestIngestion(ERP5TypeTestCase):
context.edit(file=f)
context.convertToBaseFormat()
context.reindexObject()
get_transaction().commit()
transaction.commit()
self.tic()
# We call clear cache to be sure that the target list is updated
self.getPortal().portal_caches.clearCache()
......@@ -373,7 +374,7 @@ class TestIngestion(ERP5TypeTestCase):
# reindex
ob.immediateReindexObject()
created_documents.append(ob)
get_transaction().commit()
transaction.commit()
self.tic()
# inspect created objects
count = 0
......@@ -425,7 +426,7 @@ class TestIngestion(ERP5TypeTestCase):
# pass to discovery file_name and user_login
context.discoverMetadata(context.getSourceReference(), 'john_doe')
context.reindexObject()
get_transaction().commit()
transaction.commit()
self.tic()
def checkMetadataOrder(self, expected_metadata, document_id='one'):
......@@ -471,7 +472,7 @@ class TestIngestion(ERP5TypeTestCase):
)
person.setDefaultEmailText('john@doe.com')
person.reindexObject()
get_transaction().commit()
transaction.commit()
self.tic()
def stepCreateTextDocument(self, sequence=None, sequence_list=None, **kw):
......@@ -568,7 +569,7 @@ class TestIngestion(ERP5TypeTestCase):
# Revision is 1 after upload (revisions are strings)
self.assertEquals(document.getRevision(), '1')
document.reindexObject()
get_transaction().commit()
transaction.commit()
def stepUploadFromViewForm(self, sequence=None, sequence_list=None, **kw):
"""
......@@ -580,7 +581,7 @@ class TestIngestion(ERP5TypeTestCase):
context.edit(file=f)
self.assertEquals(context.getRevision(), str(int(revision) + 1))
context.reindexObject()
get_transaction().commit()
transaction.commit()
def stepUploadTextFromContributionTool(self, sequence=None, sequence_list=None, **kw):
"""
......@@ -588,7 +589,7 @@ class TestIngestion(ERP5TypeTestCase):
"""
f = makeFileUpload('TEST-en-002.doc')
self.portal.portal_contributions.newContent(id='one', file=f)
get_transaction().commit()
transaction.commit()
def stepReuploadTextFromContributionTool(self, sequence=None, sequence_list=None, **kw):
"""
......@@ -604,16 +605,16 @@ class TestIngestion(ERP5TypeTestCase):
f.filename = 'TEST-en-002.doc'
self.portal.portal_contributions.newContent(file=f)
get_transaction().commit()
transaction.commit()
self.tic()
get_transaction().commit()
transaction.commit()
self.assertEquals(context.getRevision(), str(int(revision) + 1))
self.assert_('This document is modified.' in context.asText())
self.assertEquals(len(self.portal.document_module.objectIds()),
number_of_document)
context.reindexObject()
get_transaction().commit()
transaction.commit()
def stepUploadAnotherTextFromContributionTool(self, sequence=None, sequence_list=None, **kw):
"""
......@@ -622,9 +623,9 @@ class TestIngestion(ERP5TypeTestCase):
f = makeFileUpload('ANOTHE-en-001.doc')
self.portal.portal_contributions.newContent(id='two', file=f)
get_transaction().commit()
transaction.commit()
self.tic()
get_transaction().commit()
transaction.commit()
context = self.getDocument('two')
self.assert_('This is a another very interesting document.' in context.asText())
......@@ -689,7 +690,7 @@ class TestIngestion(ERP5TypeTestCase):
context = self.getDocument('one')
f = makeFileUpload('TEST-en-002.doc')
context.edit(file=f)
get_transaction().commit()
transaction.commit()
self.tic()
# Then make sure content discover works
property_dict = context.getPropertyDictFromUserLogin()
......@@ -712,7 +713,7 @@ class TestIngestion(ERP5TypeTestCase):
subject='another subject',
description='another description')
context.edit(**kw)
context.reindexObject(); get_transaction().commit();
context.reindexObject(); transaction.commit();
self.tic();
def stepCheckChangedMetadata(self, sequence=None, sequence_list=None, **kw):
......@@ -933,7 +934,7 @@ class TestIngestion(ERP5TypeTestCase):
"""
f = open(makeFilePath('email_from.txt'))
document = self.receiveEmail(data=f.read())
get_transaction().commit()
transaction.commit()
self.tic()
def stepReceiveEmailFromJohn(self, sequence=None, sequence_list=None, **kw):
......@@ -942,7 +943,7 @@ class TestIngestion(ERP5TypeTestCase):
"""
f = open(makeFilePath('email_from.txt'))
document = self.receiveEmail(f.read())
get_transaction().commit()
transaction.commit()
self.tic()
def stepVerifyEmailedDocuments(self, sequence=None, sequence_list=None, **kw):
......@@ -1357,7 +1358,7 @@ class TestIngestion(ERP5TypeTestCase):
f = makeFileUpload('TEST-en-002.doc', 'T&é@{T-en-002.doc')
document = self.portal.portal_contributions.newContent(file=f)
sequence.edit(document_id=document.getId())
get_transaction().commit()
transaction.commit()
def stepDiscoverFromFilenameWithNonASCIIFilename(self,
sequence=None, sequence_list=None, **kw):
......
......@@ -30,6 +30,7 @@
import unittest
import os
import transaction
from zLOG import LOG
from Testing import ZopeTestCase
from AccessControl.SecurityManagement import newSecurityManager
......@@ -751,7 +752,7 @@ class TestOOoImport(ERP5TypeTestCase):
# tests CategoryTool_importCategoryFile with * in the paths columns
self.portal.portal_categories.CategoryTool_importCategoryFile(
import_file=makeFileUpload('import_region_category_path_stars.sxc'))
get_transaction().commit()
transaction.commit()
self.tic()
region = self.portal.portal_categories.region
self.assertEqual(2, len(region))
......@@ -770,7 +771,7 @@ class TestOOoImport(ERP5TypeTestCase):
self.portal.portal_categories.CategoryTool_importCategoryFile(
import_file=makeFileUpload(
'import_region_category_path_stars_non_ascii.sxc'))
get_transaction().commit()
transaction.commit()
self.tic()
region = self.portal.portal_categories.region
self.assertEqual(2, len(region))
......@@ -789,7 +790,7 @@ class TestOOoImport(ERP5TypeTestCase):
# bug)
self.portal.portal_categories.CategoryTool_importCategoryFile(
import_file=makeFileUpload('import_region_category_duplicate_ids.sxc'))
get_transaction().commit()
transaction.commit()
self.tic()
region = self.portal.portal_categories.region
self.assertEqual(1, len(region))
......
......@@ -27,6 +27,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase
......@@ -53,7 +54,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
person_module = self.portal.person_module
if person_module._getOb('pers', None) is None:
person_module.newContent(id='pers', portal_type='Person')
get_transaction().commit()
transaction.commit()
self.tic()
person_module.pers.setFirstName('Bob')
if person_module.pers._getOb('img', None) is None:
......
......@@ -26,6 +26,7 @@
#
##############################################################################
import transaction
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base, aq_self
from OFS.History import Historical
......@@ -957,7 +958,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
f = os.path.join(dir, '%s___%s.zexp' % (folder_id,id))
ob = self._getOb(id)
ob._p_jar.exportFile(ob._p_oid,f)
get_transaction().commit()
transaction.commit()
security.declareProtected( Permissions.ModifyPortalContent, 'recursiveApply')
def recursiveApply(self, filter=dummyFilter, method=None,
......@@ -998,8 +999,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
update_list += method_message
update_list += test_after(o,REQUEST=REQUEST)
# And commit subtransaction
#get_transaction().commit(1)
get_transaction().commit() # we may use commit(1) some day XXX
#transaction.commit(1)
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)
if hasattr(obase, 'recursiveApply'):
......@@ -1043,7 +1044,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
#for object in o.objectValues():
#LOG('Folder, updateAll ',0,"object.id: %s" % object.id)
obase = aq_base(o)
get_transaction().commit()
transaction.commit()
if hasattr(obase, 'updateAll'):
update_list += o.updateAll(filter=filter, \
method=method, test_after=test_after,request=request,include=0,**kw)
......@@ -1092,7 +1093,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
self.manage_delObjects(id)
LOG("upradeObjectClass: ",0,"add new object: %s" % str(newob.id))
get_transaction().commit() # XXX this commit should be after _setObject
transaction.commit() # XXX this commit should be after _setObject
LOG("upradeObjectClass: ",0,"newob.__class__: %s" % str(newob.__class__))
self._setObject(id, newob)
object_to_test = self._getOb(id)
......@@ -1234,7 +1235,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
get_transaction().commit(1)
transaction.commit(1)
error_list += [(self.getRelativeUrl(), 'BTree Inconsistency',
199, '(fixed)')]
# Call superclass
......@@ -1242,7 +1243,7 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
# We must commit before listing folder contents
# in case we erased some data
if fixit:
get_transaction().commit(1)
transaction.commit(1)
# Then check the consistency on all sub objects
for obj in self.contentValues():
if fixit:
......
......@@ -13,6 +13,7 @@
##############################################################################
import re
import transaction
from Acquisition import aq_parent, aq_inner, aq_base
from AccessControl import ClassSecurityInfo, ModuleSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
......@@ -128,11 +129,11 @@ class TextContent:
# XXX Can we get an error msg through? Should we be raising an
# exception, to be handled in the FTP mechanism? Inquiring
# minds...
get_transaction().abort()
transaction.abort()
RESPONSE.setStatus(450)
return RESPONSE
except ResourceLockedError, msg:
get_transaction().abort()
transaction.abort()
RESPONSE.setStatus(423)
return RESPONSE
......
......@@ -31,6 +31,7 @@ try:
except ImportError:
pass
import transaction
from Testing import ZopeTestCase
from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name
from Products.ERP5Type.tests.utils import getMySQLArguments
......@@ -47,11 +48,6 @@ from Products.ERP5Type.Utils import getLocalConstraintList, \
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from zLOG import LOG, DEBUG
try:
from transaction import get as get_transaction
except ImportError:
pass
# Quiet messages when installing products
install_product_quiet = 1
# Quiet messages when installing business templates
......@@ -443,9 +439,9 @@ class ERP5TypeTestCase(PortalTestCase):
ZopeTestCase._print('\nRecreating catalog ... ')
portal.portal_activities.manageClearActivities()
portal.portal_catalog.manage_catalogClear()
get_transaction().commit()
transaction.commit()
portal.ERP5Site_reindexAll()
get_transaction().commit()
transaction.commit()
self.tic()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start,))
......@@ -666,7 +662,7 @@ class ERP5TypeTestCase(PortalTestCase):
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start))
# Release locks
get_transaction().commit()
transaction.commit()
if os.environ.get('erp5_load_data_fs'):
# Import local PropertySheets, Documents
......@@ -718,7 +714,7 @@ class ERP5TypeTestCase(PortalTestCase):
object_to_update=install_kw,
update_translation=1)
# Release locks
get_transaction().commit()
transaction.commit()
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start))
......@@ -742,7 +738,7 @@ class ERP5TypeTestCase(PortalTestCase):
setattr(app,'isIndexable', 1)
portal.portal_catalog.manage_hotReindexAll()
get_transaction().commit()
transaction.commit()
portal_activities = getattr(portal, 'portal_activities', None)
if portal_activities is not None:
......@@ -754,7 +750,7 @@ class ERP5TypeTestCase(PortalTestCase):
while message_count > 0:
portal_activities.distribute()
portal_activities.tic()
get_transaction().commit()
transaction.commit()
new_message_count = len(portal_activities.getMessageList())
if new_message_count != message_count:
if not quiet:
......@@ -778,7 +774,7 @@ class ERP5TypeTestCase(PortalTestCase):
if not quiet:
ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
ZopeTestCase._print('Data.fs created\n')
get_transaction().commit()
transaction.commit()
ZopeTestCase.close(app)
instance_home = os.environ['INSTANCE_HOME']
command = 'mysqldump --skip-extended-insert %s > %s/dump.sql' \
......@@ -805,10 +801,10 @@ class ERP5TypeTestCase(PortalTestCase):
ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
ZopeTestCase._print('Ran Unit test of %s\n' % title)
except:
get_transaction().abort()
transaction.abort()
raise
else:
get_transaction().commit()
transaction.commit()
ZopeTestCase.close(app)
if os.environ.get('erp5_load_data_fs'):
......@@ -850,7 +846,7 @@ class ERP5TypeTestCase(PortalTestCase):
"""
if kw.get('sequence', None) is None:
# in case of using not in sequence commit transaction
get_transaction().commit()
transaction.commit()
self.tic()
def publish(self, path, basic=None, env=None, extra=None,
......@@ -868,7 +864,7 @@ class ERP5TypeTestCase(PortalTestCase):
sm = getSecurityManager()
# Commit the sandbox for good measure
get_transaction().commit()
transaction.commit()
if env is None:
env = {}
......
......@@ -29,6 +29,7 @@
"""Base Class for security tests using ERP5Security and DCWorkflow
"""
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityManagement import setSecurityManager
......@@ -122,7 +123,7 @@ class SecurityTestCase(ERP5TypeTestCase):
"""Clean up for next test.
"""
self.tic()
get_transaction().abort()
transaction.abort()
self.portal.portal_caches.clearAllCache()
ERP5TypeTestCase.tearDown(self)
......
......@@ -26,15 +26,11 @@
#
##############################################################################
import transaction
from Testing import ZopeTestCase
from zLOG import LOG
import random
try:
from transaction import get as get_transaction
except ImportError:
pass
import traceback
import linecache
......@@ -112,7 +108,7 @@ class Sequence:
for idx, step in enumerate(self._step_list):
step.play(context, sequence=self, quiet=quiet)
# commit transaction after each step
get_transaction().commit()
transaction.commit()
def addStep(self,method_name,required=1,max_replay=1):
new_step = Step(method_name=method_name,
......
......@@ -27,6 +27,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
......@@ -118,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()
get_transaction().commit(1)
transaction.commit(1)
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)
......
......@@ -26,6 +26,7 @@
#
##############################################################################
import transaction
import unittest
import os
......@@ -64,10 +65,10 @@ class TestConstraint(PropertySheetTestCase):
self.createCategories()
def beforeTearDown(self):
get_transaction().abort()
transaction.abort()
module = self.portal.organisation_module
module.manage_delObjects(list(module.objectIds()))
get_transaction().commit()
transaction.commit()
self.tic()
def stepTic(self,**kw):
......@@ -99,7 +100,7 @@ class TestConstraint(PropertySheetTestCase):
"""
module = self.portal.getDefaultModule(self.object_portal_type)
obj = module.newContent(portal_type=self.object_portal_type)
get_transaction().commit()
transaction.commit()
self.tic()
return obj
......@@ -1120,7 +1121,7 @@ class TestConstraint(PropertySheetTestCase):
self.assertEquals(1, len(message_list))
self.assertNotEquals('', message_list[0].getTranslatedMessage())
related_obj.setGroupValue(obj)
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEquals(0, len(constraint.checkConsistency(obj)))
......
......@@ -27,6 +27,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
#from AccessControl.SecurityManagement import newSecurityManager
......@@ -58,20 +59,20 @@ class TestCopySupport(ERP5TypeTestCase):
portal_type='Organisation')
person = self.person_module.newContent(portal_type='Person',
career_subordination_value=organisation)
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(0, len(self.portal.portal_activities.getMessageList()))
self.assertTrue(person.getCareerSubordination().startswith('organisation_module'))
self.assertTrue(person.getCareerSubordinationValue().aq_base is organisation.aq_base)
# Try to rename: must work
self.organisation_module.setId('new_organisation_module')
get_transaction().commit()
transaction.commit()
self.assertTrue(person.getCareerSubordination().startswith('organisation_module'))
initial_activity_count = len(self.portal.portal_activities.getMessageList())
self.assertNotEqual(0, initial_activity_count)
# Try to rename again with pending activities: must raise
self.assertRaises(ActivityPendingError, self.organisation_module.setId, 'organisation_module')
get_transaction().commit()
transaction.commit()
# Activity count must not have changed
self.assertEqual(initial_activity_count, len(self.portal.portal_activities.getMessageList()))
self.tic()
......@@ -80,7 +81,7 @@ class TestCopySupport(ERP5TypeTestCase):
self.assertTrue(person.getCareerSubordinationValue().aq_base is organisation.aq_base)
# Rename back to original name
self.organisation_module.setId('organisation_module')
get_transaction().commit()
transaction.commit()
self.tic()
# Check that relation is back to what it was
self.assertTrue(person.getCareerSubordination().startswith('organisation_module'))
......
This diff is collapsed.
......@@ -29,6 +29,7 @@
##############################################################################
import unittest
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
......@@ -63,7 +64,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.folder.manage_delObjects(ids=list(self.folder.objectIds()))
self.getPortal().manage_delObjects(ids=[self.folder.getId(),])
clearCache()
get_transaction().commit()
transaction.commit()
self.tic()
def newContent(self, *args, **kwargs):
......@@ -101,12 +102,12 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree(migration_generate_id_method="Base_generateIdFromStopDate",
new_generate_id_method="_generatePerDayId")
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -170,7 +171,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
# call migration script
self.folder.migrateToHBTree(migration_generate_id_method=None,
new_generate_id_method="_generatePerDayId")
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -201,11 +202,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -238,11 +239,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -263,7 +264,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
# set id generator
id_generator_method = '_generatePerDayId'
self.folder.setIdGenerator(id_generator_method)
get_transaction().commit()
transaction.commit()
self.assertEquals(self.folder.getIdGenerator(), id_generator_method)
# check object ids
self.assertEquals(obj1.getId(), '1')
......@@ -295,12 +296,12 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree(migration_generate_id_method="Base_generateIdFromStopDate",
new_generate_id_method="_generatePerDayId")
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -326,7 +327,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
# call migration script again
self.folder.migrateToHBTree(migration_generate_id_method="Base_generateIdFromStopDate",
new_generate_id_method="_generatePerDayId")
get_transaction().commit()
transaction.commit()
self.tic()
# check object ids
......@@ -352,15 +353,15 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script twice
self.folder.migrateToHBTree(migration_generate_id_method="Base_generateIdFromStopDate",
new_generate_id_method="_generatePerDayId")
get_transaction().commit()
transaction.commit()
self.folder.migrateToHBTree(migration_generate_id_method="Base_generateIdFromStopDate",
new_generate_id_method="_generatePerDayId")
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -399,11 +400,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
obj4 = self.newContent(id='BASE-123')
self.assertEquals(obj4.getId(), 'BASE-123')
......@@ -428,11 +429,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEquals(obj2.getId(), '2')
obj3 = self.newContent()
self.assertEquals(obj3.getId(), '3')
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
obj4 = self.newContent(id='BASE-123')
obj5 = self.newContent(id='BASE-BELONG-123')
......@@ -455,7 +456,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
message = 'Test folderIsBtree'
LOG('Testing... ', 0, message)
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
infolder = self.newContent()
......@@ -483,11 +484,11 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
obj1 = self.newContent(id=obj1_id)
obj2 = self.newContent(id=obj2_id)
obj3 = self.newContent(id=obj3_id)
get_transaction().commit()
transaction.commit()
self.tic()
# call migration script
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
# check we now have a hbtree
self.assertEqual(self.folder.isBTree(), False)
......@@ -515,20 +516,20 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(self.folder.isHBTree(), False)
setattr(self.folder,'_folder_handler','VeryWrongHandler')
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(self.folder.isBTree(), False)
self.assertEqual(self.folder.isHBTree(), False)
self.assertEquals(self.folder._fixFolderHandler(), True)
get_transaction().commit()
transaction.commit()
self.assertEqual(self.folder.isBTree(), True)
self.assertEqual(self.folder.isHBTree(), False)
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(self.folder.isBTree(), False)
......@@ -544,21 +545,21 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(self.folder.isHBTree(), False)
setattr(self.folder,'_folder_handler','VeryWrongHandler')
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(self.folder.isBTree(), False)
self.assertEqual(self.folder.isHBTree(), False)
self.folder.migrateToHBTree()
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(self.folder.isBTree(), False)
self.assertEqual(self.folder.isHBTree(), True)
self.folder.newContent()
get_transaction().commit()
transaction.commit()
self.tic()
self.assertEqual(self.folder.isBTree(), False)
......
......@@ -29,6 +29,7 @@
import unittest
import os
import transaction
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.utils import installRealMemcachedTool
......@@ -121,7 +122,7 @@ class TestMemcachedTool(ERP5TypeTestCase):
# First, check that the local cache in memcachedTool works
tested_dict[tested_key] = tested_value
self.assertTrue(tested_dict[tested_key] is tested_value)
get_transaction().commit()
transaction.commit()
# After a commit, check that the value is commited and grabbed from memcached
# again. Its value must not change, but the instance is not the same anymore.
self.assertTrue(tested_dict[tested_key] is not tested_value)
......@@ -151,7 +152,7 @@ class TestMemcachedTool(ERP5TypeTestCase):
tested_dict[tested_key] = tested_value
self.assertTrue(tested_dict[tested_key] == tested_value)
del tested_dict[tested_key]
get_transaction().commit()
transaction.commit()
try:
dummy = tested_dict[tested_key]
except KeyError:
......
......@@ -30,6 +30,7 @@ import unittest
from time import time
import gc
import transaction
from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zLOG import LOG
......@@ -99,13 +100,13 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
def beforeTearDown(self):
# Re-enable gc at teardown.
gc.enable()
get_transaction().abort()
transaction.abort()
self.bar_module.manage_delObjects(list(self.bar_module.objectIds()))
self.foo_module.manage_delObjects(list(self.foo_module.objectIds()))
gender = self.getPortal().portal_categories['gender']
gender.manage_delObjects(list(gender.objectIds()))
gender = self.getPortal().portal_caches.clearAllCache()
get_transaction().commit()
transaction.commit()
self.tic()
def checkViewBarObject(self, min, max, quiet=quiet, prefix=None):
......@@ -123,7 +124,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Bar Test',
quantity=10000,)
bar.setReference(bar.getRelativeUrl())
get_transaction().commit()
transaction.commit()
self.tic()
# Check performance
before_view = time()
......@@ -181,7 +182,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
if not quiet:
message = 'Test form to view Bar module'
LOG('Testing... ', 0, message)
get_transaction().commit()
transaction.commit()
self.tic()
view_result = {}
tic_result = {}
......@@ -194,7 +195,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Bar Test',
quantity="%4d" %(x,))
after_add = time()
get_transaction().commit()
transaction.commit()
before_tic = time()
self.tic()
after_tic = time()
......@@ -261,7 +262,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
title='Line 1')
foo.newContent(portal_type='Foo Line',
title='Line 2')
get_transaction().commit()
transaction.commit()
self.tic()
# Check performance
before_view = time()
......@@ -292,7 +293,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
for i in xrange(100):
foo.newContent(portal_type='Foo Line',
title='Line %s' % i)
get_transaction().commit()
transaction.commit()
self.tic()
# Check performance
before_view = time()
......
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