[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/Zope2/App/ Backported DoomedTransaction handling from trunk r92792 to 2.11 branch
Log message for revision 92793: Backported DoomedTransaction handling from trunk r92792 to 2.11 branch Changed: U Zope/branches/2.11/lib/python/Zope2/App/startup.py A Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py -=- Modified: Zope/branches/2.11/lib/python/Zope2/App/startup.py === --- Zope/branches/2.11/lib/python/Zope2/App/startup.py 2008-11-05 12:41:21 UTC (rev 92792) +++ Zope/branches/2.11/lib/python/Zope2/App/startup.py 2008-11-05 13:08:33 UTC (rev 92793) @@ -249,7 +249,15 @@ REQUEST['AUTHENTICATED_USER'] = AccessControl.User.nobody try: -f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) +result = f(client, REQUEST, t, v, + traceback, + error_log_url=error_log_url) +if result is not None: +t, v, traceback = result +response = REQUEST.RESPONSE +response.setStatus(t) +response.setBody(v) +return response except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) @@ -267,7 +275,10 @@ transaction.begin() def commit(self): -transaction.commit() +if hasattr(transaction, 'isDoomed') and transaction.isDoomed(): +transaction.abort() +else: +transaction.commit() def abort(self): transaction.abort() Copied: Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py (from rev 92792, Zope/trunk/lib/python/Zope2/App/tests/testDoomedTransaction.py) === --- Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py (rev 0) +++ Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py 2008-11-05 13:08:33 UTC (rev 92793) @@ -0,0 +1,43 @@ +## +# +# 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') ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] [Checkins] SVN: Zope/branches/2.11/lib/python/Zope2/App/ Backported DoomedTransaction handling from trunk r92792 to 2.11 branch
Hi Matthew, I think you merged a little bit too much here. You picked the previous revision of startup.py by accident. On Wed, Nov 5, 2008 at 11:08 AM, Matthew Wilkes [EMAIL PROTECTED] wrote: Log message for revision 92793: Backported DoomedTransaction handling from trunk r92792 to 2.11 branch Changed: U Zope/branches/2.11/lib/python/Zope2/App/startup.py A Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py -=- Modified: Zope/branches/2.11/lib/python/Zope2/App/startup.py === --- Zope/branches/2.11/lib/python/Zope2/App/startup.py 2008-11-05 12:41:21 UTC (rev 92792) +++ Zope/branches/2.11/lib/python/Zope2/App/startup.py 2008-11-05 13:08:33 UTC (rev 92793) @@ -249,7 +249,15 @@ REQUEST['AUTHENTICATED_USER'] = AccessControl.User.nobody try: -f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) +result = f(client, REQUEST, t, v, + traceback, + error_log_url=error_log_url) +if result is not None: +t, v, traceback = result +response = REQUEST.RESPONSE +response.setStatus(t) +response.setBody(v) +return response except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) @@ -267,7 +275,10 @@ transaction.begin() def commit(self): -transaction.commit() +if hasattr(transaction, 'isDoomed') and transaction.isDoomed(): +transaction.abort() +else: +transaction.commit() def abort(self): transaction.abort() Copied: Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py (from rev 92792, Zope/trunk/lib/python/Zope2/App/tests/testDoomedTransaction.py) === --- Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py (rev 0) +++ Zope/branches/2.11/lib/python/Zope2/App/tests/testDoomedTransaction.py 2008-11-05 13:08:33 UTC (rev 92793) @@ -0,0 +1,43 @@ +## +# +# 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') ___ Checkins mailing list [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/checkins -- Sidnei da Silva Enfold Systems http://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 Skype zopedc ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/Zope2/App/startup.py Good catch Sidnei, damn you unexpected merge
Log message for revision 92794: Good catch Sidnei, damn you unexpected merge Changed: U Zope/branches/2.11/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/2.11/lib/python/Zope2/App/startup.py === --- Zope/branches/2.11/lib/python/Zope2/App/startup.py 2008-11-05 13:08:33 UTC (rev 92793) +++ Zope/branches/2.11/lib/python/Zope2/App/startup.py 2008-11-05 13:17:50 UTC (rev 92794) @@ -249,15 +249,7 @@ REQUEST['AUTHENTICATED_USER'] = AccessControl.User.nobody try: -result = f(client, REQUEST, t, v, - traceback, - error_log_url=error_log_url) -if result is not None: -t, v, traceback = result -response = REQUEST.RESPONSE -response.setStatus(t) -response.setBody(v) -return response +f(client, REQUEST, t, v, traceback, error_log_url=error_log_url) except TypeError: # Pre 2.6 call signature f(client, REQUEST, t, v, traceback) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Zope2/App/ Add check for doomed transactions in default transaction manager, abort silently if the tm tries to commit a doomed transaction
Log message for revision 92792: Add check for doomed transactions in default transaction manager, abort silently if the tm tries to commit a doomed transaction Changed: U Zope/trunk/lib/python/Zope2/App/startup.py A Zope/trunk/lib/python/Zope2/App/tests/testDoomedTransaction.py -=- Modified: Zope/trunk/lib/python/Zope2/App/startup.py === --- Zope/trunk/lib/python/Zope2/App/startup.py 2008-11-05 11:07:33 UTC (rev 92791) +++ Zope/trunk/lib/python/Zope2/App/startup.py 2008-11-05 12:41:21 UTC (rev 92792) @@ -281,7 +281,10 @@ transaction.begin() def commit(self): -transaction.commit() +if hasattr(transaction, 'isDoomed') and transaction.isDoomed(): +transaction.abort() +else: +transaction.commit() def abort(self): transaction.abort() Added: Zope/trunk/lib/python/Zope2/App/tests/testDoomedTransaction.py === --- Zope/trunk/lib/python/Zope2/App/tests/testDoomedTransaction.py (rev 0) +++ Zope/trunk/lib/python/Zope2/App/tests/testDoomedTransaction.py 2008-11-05 12:41:21 UTC (rev 92792) @@ -0,0 +1,43 @@ +## +# +# 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') ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-dev] Zope Tests: 4 OK, 2 Failed
Summary of messages to the zope-tests list. Period Tue Nov 4 12:00:00 2008 UTC to Wed Nov 5 12:00:00 2008 UTC. There were 6 messages: 6 from Zope Tests. Test failures - Subject: FAILED (failures=2) : Zope-trunk Python-2.4.5 : Linux From: Zope Tests Date: Tue Nov 4 21:08:38 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-November/010428.html Subject: FAILED (failures=2) : Zope-trunk Python-2.5.2 : Linux From: Zope Tests Date: Tue Nov 4 21:10:08 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-November/010429.html Tests passed OK --- Subject: OK : Zope-2.8 Python-2.3.7 : Linux From: Zope Tests Date: Tue Nov 4 21:02:37 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-November/010424.html Subject: OK : Zope-2.9 Python-2.4.5 : Linux From: Zope Tests Date: Tue Nov 4 21:04:07 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-November/010425.html Subject: OK : Zope-2.10 Python-2.4.5 : Linux From: Zope Tests Date: Tue Nov 4 21:05:37 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-November/010426.html Subject: OK : Zope-2.11 Python-2.4.5 : Linux From: Zope Tests Date: Tue Nov 4 21:07:08 EST 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-November/010427.html ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] SVN: Zope/trunk/lib/python/Zope2/App/ Add check for doomed transactions in default transaction manager, abort silently if the tm tries to commit a doomed transaction
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Matthew Wilkes wrote: Log message for revision 92792: Add check for doomed transactions in default transaction manager, abort silently if the tm tries to commit a doomed transaction Why is this a good thing? Do you have real use cases where doomed transactions are causing tracebacks, and where that isn't just a bug in your code which you should be fixing? Tres. - -- === Tres Seaver +1 540-429-0999 [EMAIL PROTECTED] Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJEjlC+gerLs4ltQ4RAn91AKCuYBYT37Ajru4oGKkwnqvTkD/a1QCfRrdd QGVLYDPGvxs3vTTE8A9O27Y= =P3Ws -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope] FunctionalTestCase commits transactions
2008/11/4 Dieter Maurer [EMAIL PROTECTED]: Ross Patterson wrote at 2008-11-3 16:04 -0800: ... If memory serves, a *functional* test fixture calls the Zope publisher when a testbrowser request is made. The publisher opens a new transaction, as it should. Really? When I wrote a functional test browser (years before zope3), I emulated the Zope publisher rather than calling it directly in order to have control how transactions are handled. Especially, I used subtransactions instead of top level transactions to avoid the bug reported by Peter. Uh? subtransactions? So how would you recommend that I go abouts doing this? In fact I've already written a custom tearDown() for my class that cleans the test database (postgresql) which is quite neat because I can write tests in a completely different way as each test can build on each other (assuming order of methods is respected) similar to how doctests are done where you have blocks of shell code split between text. If this is the way it has to be to test with zope.testbrowser in zope 2 then I'll let it be so. -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] FunctionalTestCase commits transactions
Peter Bengtsson [EMAIL PROTECTED] writes: 2008/11/4 Dieter Maurer [EMAIL PROTECTED]: Ross Patterson wrote at 2008-11-3 16:04 -0800: ... If memory serves, a *functional* test fixture calls the Zope publisher when a testbrowser request is made. The publisher opens a new transaction, as it should. Really? When I wrote a functional test browser (years before zope3), I emulated the Zope publisher rather than calling it directly in order to have control how transactions are handled. Especially, I used subtransactions instead of top level transactions to avoid the bug reported by Peter. Uh? subtransactions? So how would you recommend that I go abouts doing this? In fact I've already written a custom tearDown() for my class that cleans the test database (postgresql) which is quite neat because I can write tests in a completely different way as each test can build on each other (assuming order of methods is respected) similar to how doctests are done where you have blocks of shell code split between text. If this is the way it has to be to test with zope.testbrowser in zope 2 then I'll let it be so. I don't think what Dieter is talking about is a viable path for you. I think he's talking about something *else* that he did in the past. I think you should use your approach or the one I suggested. Ross ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )