[Zope-Checkins] CVS: Zope/lib/python/ZPublisher -
Publish.py:1.164.2.4
Chris McDonough
chrism at plope.com
Sun May 23 01:54:15 EDT 2004
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv11224/lib/python/ZPublisher
Modified Files:
Tag: Zope-2_7-branch
Publish.py
Log Message:
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.
=== Zope/lib/python/ZPublisher/Publish.py 1.164.2.3 => 1.164.2.4 ===
--- Zope/lib/python/ZPublisher/Publish.py:1.164.2.3 Sun May 23 01:36:46 2004
+++ Zope/lib/python/ZPublisher/Publish.py Sun May 23 01:53:44 2004
@@ -108,8 +108,6 @@
return response
except:
- if transactions_manager:
- transactions_manager.abort()
# DM: provide nicer error message for FTP
sm = None
@@ -127,19 +125,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:
@@ -148,6 +156,8 @@
newrequest.close()
else:
+ if transactions_manager:
+ transactions_manager.abort()
raise
More information about the Zope-Checkins
mailing list