[Checkins] SVN: zope.app.publication/trunk/ merge of branch adamg-transient
Adam Groszer
cvs-admin at zope.org
Fri Mar 9 15:17:08 UTC 2012
Log message for revision 124535:
merge of branch adamg-transient
Changed:
U zope.app.publication/trunk/CHANGES.txt
U zope.app.publication/trunk/setup.py
U zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py
U zope.app.publication/trunk/src/zope/app/publication/zopepublication.py
-=-
Modified: zope.app.publication/trunk/CHANGES.txt
===================================================================
--- zope.app.publication/trunk/CHANGES.txt 2012-03-09 15:08:56 UTC (rev 124534)
+++ zope.app.publication/trunk/CHANGES.txt 2012-03-09 15:17:04 UTC (rev 124535)
@@ -5,9 +5,14 @@
3.14 (unreleased)
-----------------
-- Nothing changed yet.
+- Replace ZODB.POSException.ConflictError with
+ transaction.interfaces.TransientError. The latter should be a more generic
+ signal to retry a transaction/request.
+ This requires ZODB3 >= 3.10.0 and transaction >= 1.1.0.
+- Get rid of ZODB dependency.
+
3.13.2 (2011-08-04)
-------------------
Modified: zope.app.publication/trunk/setup.py
===================================================================
--- zope.app.publication/trunk/setup.py 2012-03-09 15:08:56 UTC (rev 124534)
+++ zope.app.publication/trunk/setup.py 2012-03-09 15:17:04 UTC (rev 124535)
@@ -64,9 +64,9 @@
'zope.security',
'zope.securitypolicy',
'zope.site',
- 'zope.testing']),
+ 'zope.testing',
+ 'ZODB3>=3.10']),
install_requires=['zope.interface',
- 'ZODB3',
'zope.authentication',
'zope.component',
'zope.error',
@@ -74,6 +74,7 @@
'zope.location',
'zope.publisher>=3.12.4',
'zope.traversing>=3.9.0',
+ 'transaction>=1.1.0',
'setuptools',
],
include_package_data = True,
Modified: zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py 2012-03-09 15:08:56 UTC (rev 124534)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py 2012-03-09 15:17:04 UTC (rev 124535)
@@ -172,9 +172,19 @@
verifyClass(interface, TestPublication)
def testRetryAllowed(self):
- from ZODB.POSException import ConflictError
from zope.publisher.interfaces import Retry
+
+ # a more generic version of ConflictError, but is the better thing
+ from transaction.interfaces import TransientError
try:
+ raise TransientError
+ except:
+ self.assertRaises(Retry, self.publication.handleException,
+ self.object, self.request, sys.exc_info(), retry_allowed=True)
+
+ # be nice and check ZODB's ConflictError
+ from ZODB.POSException import ConflictError
+ try:
raise ConflictError
except:
self.assertRaises(Retry, self.publication.handleException,
@@ -187,8 +197,20 @@
self.object, self.request, sys.exc_info(), retry_allowed=True)
def testRetryNotAllowed(self):
+ from transaction.interfaces import TransientError
+ try:
+ raise TransientError
+ except:
+ self.publication.handleException(
+ self.object, self.request, sys.exc_info(), retry_allowed=False)
+ value = ''.join(self.request.response._result).split()
+ self.assertEqual(' '.join(value[:6]),
+ 'Traceback (most recent call last): File')
+ self.assertEqual(' '.join(value[-5:]),
+ 'in testRetryNotAllowed raise TransientError'
+ ' TransientError')
+
from ZODB.POSException import ConflictError
- from zope.publisher.interfaces import Retry
try:
raise ConflictError
except:
@@ -201,6 +223,7 @@
'in testRetryNotAllowed raise ConflictError'
' ConflictError: database conflict error')
+ from zope.publisher.interfaces import Retry
try:
raise Retry(sys.exc_info())
except:
@@ -380,6 +403,22 @@
self.assertEqual(self.object, adapter.obj)
self.assertEqual(self.request, adapter.request)
+ def testExceptionResetsResponseTransientError(self):
+ from zope.publisher.browser import TestRequest
+ request = TestRequest()
+ request.response.setHeader('Content-Type', 'application/pdf')
+ request.response.setCookie('spam', 'eggs')
+ from transaction.interfaces import TransientError
+ try:
+ raise TransientError
+ except:
+ pass
+ self.publication.handleException(
+ self.object, request, sys.exc_info(), retry_allowed=False)
+ self.assertEqual(request.response.getHeader('Content-Type'),
+ 'text/html;charset=utf-8')
+ self.assertEqual(request.response._cookies, {})
+
def testExceptionResetsResponse(self):
from zope.publisher.browser import TestRequest
request = TestRequest()
Modified: zope.app.publication/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/zopepublication.py 2012-03-09 15:08:56 UTC (rev 124534)
+++ zope.app.publication/trunk/src/zope/app/publication/zopepublication.py 2012-03-09 15:17:04 UTC (rev 124535)
@@ -17,14 +17,12 @@
import logging
from new import instancemethod
-from ZODB.POSException import ConflictError
import transaction
import zope.component
import zope.component.interfaces
from zope.component import queryMultiAdapter
from zope.event import notify
-from zope.security.interfaces import Unauthorized
from zope.interface import implements, providedBy
from zope.publisher.publish import mapply
from zope.publisher.interfaces import IExceptionSideEffects, IHeld
@@ -300,7 +298,9 @@
raise
# Convert ConflictErrors to Retry exceptions.
- if retry_allowed and isinstance(exc_info[1], ConflictError):
+ # where transaction.interfaces.TransientError is a more generic exception
+ if retry_allowed and isinstance(exc_info[1],
+ transaction.interfaces.TransientError):
tryToLogWarning(
'ZopePublication',
'Competing writes/reads at %s: %s'
More information about the checkins
mailing list