Commit e9ed54f5 authored by Matthew Wilkes's avatar Matthew Wilkes

Add check for doomed transactions in default transaction manager, abort...

Add check for doomed transactions in default transaction manager, abort silently if the tm tries to commit a doomed transaction
parent 99bee71e
...@@ -281,7 +281,10 @@ class TransactionsManager: ...@@ -281,7 +281,10 @@ class TransactionsManager:
transaction.begin() transaction.begin()
def commit(self): def commit(self):
transaction.commit() if hasattr(transaction, 'isDoomed') and transaction.isDoomed():
transaction.abort()
else:
transaction.commit()
def abort(self): def abort(self):
transaction.abort() transaction.abort()
......
##############################################################################
#
# Copyright (c) 2007 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import sys
import unittest
import logging
import transaction
class DoomedTransactionInManagerTest(unittest.TestCase):
def testDoomedFails(self):
transaction.begin()
trans = transaction.get()
trans.doom()
from transaction.interfaces import DoomedTransaction
self.assertRaises(DoomedTransaction, trans.commit)
def testDoomedSilentInTM(self):
from Zope2.App.startup import TransactionsManager
tm = TransactionsManager()
transaction.begin()
trans = transaction.get()
trans.doom()
tm.commit()
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(DoomedTransactionInManagerTest))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
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