[Zope-Checkins] SVN: Zope/trunk/lib/python/Z Merge from 2.7 branch:
Chris McDonough
chrism at plope.com
Sun May 23 01:55:43 EDT 2004
Log message for revision 24892:
Merge from 2.7 branch:
Collector 789: Zope's transaction behavior flawed.
Historically, errors that made it up to the publisher have run outside the
context of a transaction. This has caused problems for applications which
expect to be able to write to the database (if only temporarily, before
transaction.abort() is eventually called).
With this patch, we allow the error to execute in the same transaction as
the "main" request, and abort only after the error has executed.
-=-
Modified: Zope/trunk/lib/python/ZPublisher/Publish.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/Publish.py 2004-05-23 05:37:15 UTC (rev 24891)
+++ Zope/trunk/lib/python/ZPublisher/Publish.py 2004-05-23 05:55:43 UTC (rev 24892)
@@ -119,8 +119,6 @@
return response
except:
- if transactions_manager:
- transactions_manager.abort()
# DM: provide nicer error message for FTP
sm = None
@@ -138,19 +136,29 @@
if parents:
parents=parents[0]
try:
- return err_hook(parents, request,
- sys.exc_info()[0],
- sys.exc_info()[1],
- sys.exc_info()[2],
- )
- except Retry:
- # We need to try again....
- if not request.supports_retry():
- return err_hook(parents, request,
+ response = err_hook(parents, request,
sys.exc_info()[0],
sys.exc_info()[1],
sys.exc_info()[2],
)
+ if transactions_manager:
+ transactions_manager.abort()
+ return response
+
+ except Retry:
+ if not request.supports_retry():
+ response = err_hook(parents, request,
+ sys.exc_info()[0],
+ sys.exc_info()[1],
+ sys.exc_info()[2],
+ )
+ if transactions_manager:
+ transactions_manager.abort()
+ return response
+
+
+ if transactions_manager:
+ transactions_manager.abort()
newrequest=request.retry()
request.close() # Free resources held by the request.
try:
@@ -159,6 +167,8 @@
newrequest.close()
else:
+ if transactions_manager:
+ transactions_manager.abort()
raise
Modified: Zope/trunk/lib/python/Zope/App/startup.py
===================================================================
--- Zope/trunk/lib/python/Zope/App/startup.py 2004-05-23 05:37:15 UTC (rev 24891)
+++ Zope/trunk/lib/python/Zope/App/startup.py 2004-05-23 05:55:43 UTC (rev 24892)
@@ -179,8 +179,6 @@
published=app.__bobo_traverse__(REQUEST).__of__(
RequestContainer(REQUEST))
- get_transaction().begin() # Just to be sure.
-
published=getattr(published, 'im_self', published)
while 1:
f=getattr(published, 'raise_standardErrorMessage', None)
More information about the Zope-Checkins
mailing list