[Zope-Checkins] SVN: Zope/trunk/ Merged r40454 from 2.9 branch:

Florent Guillaume fg at nuxeo.com
Thu Dec 1 13:46:45 EST 2005


Log message for revision 40455:
  Merged r40454 from 2.9 branch:
  Improved logging of ConflictErrors. Now a log is made at level BLATHER
  with traceback for any conflict retried. In addition, a log is made at
  level ERROR for a conflict that can't be retried anymore and is returned
  to the browser as an error. Nothing is logged anymore at level INFO.
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Zope2/App/startup.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2005-12-01 18:39:12 UTC (rev 40454)
+++ Zope/trunk/doc/CHANGES.txt	2005-12-01 18:46:44 UTC (rev 40455)
@@ -26,6 +26,12 @@
 
     Features added
 
+      - Improved logging of ConflictErrors. Now a log is made at level
+        BLATHER with traceback for any conflict retried. In addition, a
+        log is made at level ERROR for a conflict that can't be retried
+        anymore and is returned to the browser as an error. Nothing is
+        logged anymore at level INFO.
+
       - Use new-style security declarations everywhere possible. This
         means remove the use of __ac_permissions__, foo__roles__ and
         default__class_init__. A few corner cases can't be converted

Modified: Zope/trunk/lib/python/Zope2/App/startup.py
===================================================================
--- Zope/trunk/lib/python/Zope2/App/startup.py	2005-12-01 18:39:12 UTC (rev 40454)
+++ Zope/trunk/lib/python/Zope2/App/startup.py	2005-12-01 18:46:44 UTC (rev 40455)
@@ -20,7 +20,7 @@
 from App.config import getConfiguration
 from types import StringType, ListType
 from zExceptions import Unauthorized
-from zLOG import LOG, WARNING, INFO, BLATHER, log_time
+from zLOG import LOG, ERROR, WARNING, INFO, BLATHER, log_time
 from ZODB.POSException import ConflictError
 import transaction
 import AccessControl.User
@@ -142,20 +142,25 @@
             if t is SystemExit:
                 raise
             if issubclass(t, ConflictError):
-                # First, we need to close the current connection. We'll
-                # do this by releasing the hold on it. There should be
-                # some sane protocol for this, but for now we'll use
-                # brute force:
                 global conflict_errors
                 conflict_errors = conflict_errors + 1
                 method_name = REQUEST.get('PATH_INFO', '')
-                err = ('ZODB conflict error at %s '
-                       '(%s conflicts since startup at %s)')
-                LOG(err % (method_name, conflict_errors, startup_time),
-                    INFO, '')
-                LOG('Conflict traceback', BLATHER, '', error=sys.exc_info())
+                LOG('ZODB', BLATHER, "%s at %s: %s"
+                    " (%s conflicts since startup at %s)"
+                    % (v.__class__.__name__, method_name, v,
+                       conflict_errors, startup_time),
+                    error=(t, v, traceback))
                 raise ZPublisher.Retry(t, v, traceback)
-            if t is ZPublisher.Retry: v.reraise()
+            if t is ZPublisher.Retry:
+                # An exception that can't be retried anymore
+                # Retrieve the original exception
+                try: v.reraise()
+                except: t, v, traceback = sys.exc_info()
+                # Log it as ERROR
+                method_name = REQUEST.get('PATH_INFO', '')
+                LOG('Publisher', ERROR, "Unhandled %s at %s: %s"
+                    % (v.__class__.__name__, method_name, v))
+                # Then fall through to display the error to the user
 
         try:
             log = aq_acquire(published, '__error_log__', containment=1)



More information about the Zope-Checkins mailing list