[ZODB-Dev] Re: BTrees strangeness (was [Zope-dev] Zope 2.X BIG Session problems - blocker - our site dies - need help of experience Zope developer, please)

Michael Dunstan michael at looma.co.nz
Fri May 14 22:49:15 EDT 2004


On 14/05/2004, at 10:06 AM, Chris McDonough wrote:

> I am tempted to check the following into the 2.7 branch and HEAD:
>
> - "error occurs in same transaction as main request" patch
>   to Publish.py.  See
> http://www.plope.com/Members/chrism/ 
> publishpy_errorinmaintrainsaction.patch/file_view
>  for the patch.

hmm... I suspect there are few holes in this...

- Need to make sure there is no get_transaction().begin() in  
zpublisher_exception_hook() of lib/python/Zope/App/startup.py

   That begin() would mean that the error handling is not in fact part  
of the original transaction?

- An exception within err_hook() (aside from a Retry) will mean that  
abort() is never called.

Here is another attempt at publishpy_errorinmaintrainsaction.patch:


Index: lib/python/ZPublisher/Publish.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/ZPublisher/Publish.py,v
retrieving revision 1.164.2.2
diff -u -r1.164.2.2 Publish.py
--- lib/python/ZPublisher/Publish.py    17 Nov 2003 22:34:19 -0000       
1.164.2.2
+++ lib/python/ZPublisher/Publish.py    15 May 2004 02:34:12 -0000
@@ -105,7 +105,6 @@

          return response
      except:
-        if transactions_manager: transactions_manager.abort()

          # DM: provide nicer error message for FTP
          sm = None
@@ -119,29 +118,36 @@


          if err_hook is not None:
-            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():
+                if parents: parents=parents[0]
+                try:
                      return err_hook(parents, request,
                                      sys.exc_info()[0],
                                      sys.exc_info()[1],
                                      sys.exc_info()[2],
                                      )
-                newrequest=request.retry()
-                request.close()  # Free resources held by the request.
-                try:
-                    return publish(newrequest, module_name,  
after_list, debug)
-                finally:
-                    newrequest.close()
+                except Retry:
+                    if not request.supports_retry():
+                        return err_hook(parents, request,
+                                        sys.exc_info()[0],
+                                        sys.exc_info()[1],
+                                        sys.exc_info()[2],
+                                        )
+            finally:
+                if transactions_manager: transactions_manager.abort()
+
+
+            newrequest=request.retry()
+            request.close()  # Free resources held by the request.
+            try:
+                return publish(newrequest, module_name, after_list,  
debug)
+            finally:
+                newrequest.close()
+
+        else:
+            if transactions_manager: transactions_manager.abort()
+            raise

-        else: raise


  def publish_module_standard(module_name,
Index: lib/python/Zope/App/startup.py
===================================================================
RCS file: /cvs-repository/Zope/lib/python/Zope/App/startup.py,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 startup.py
--- lib/python/Zope/App/startup.py      20 Dec 2003 04:48:36 -0000       
1.8.2.3
+++ lib/python/Zope/App/startup.py      15 May 2004 02:34:13 -0000
@@ -176,8 +176,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-Dev mailing list