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