[Checkins] SVN: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py Defer closing the request until the transaction commits.

Tres Seaver tseaver at palladion.com
Sat May 29 15:20:16 EDT 2010


Log message for revision 112843:
  Defer closing the request until the transaction commits.
  
  But only if we know that middleware is handling the transaction.

Changed:
  U   Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py

-=-
Modified: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py
===================================================================
--- Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py	2010-05-29 19:20:13 UTC (rev 112842)
+++ Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py	2010-05-29 19:20:16 UTC (rev 112843)
@@ -19,6 +19,7 @@
 from zExceptions import Unauthorized
 from ZServer.medusa.http_date import build_http_date
 
+
 from ZPublisher.HTTPResponse import HTTPResponse
 from ZPublisher.HTTPRequest import HTTPRequest
 from ZPublisher.mapply import mapply
@@ -211,7 +212,13 @@
         # XXX This still needs verification that it really works.
         result=(stdout.getvalue(), response.body)
 
-    request.close()
+    if 'repoze.tm.active' in environ:
+        import transaction
+        txn = transaction.get()
+        txn.addAfterCommitHook(lambda ok: request.close())
+    else:
+        request.close() # this aborts the transation!
+
     stdout.close()
 
     if after_list[0] is not None:



More information about the checkins mailing list