Commit 00a23f44 authored by Florent Guillaume's avatar Florent Guillaume

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.
parent 26ca780e
...@@ -24,7 +24,13 @@ Zope Changes ...@@ -24,7 +24,13 @@ Zope Changes
Trunk only (unreleased) Trunk only (unreleased)
Features added 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.
- Fixed unclear security declarations. Warn when an attempt is - Fixed unclear security declarations. Warn when an attempt is
made to have a security declaration on a nonexistent method. made to have a security declaration on a nonexistent method.
......
...@@ -20,7 +20,7 @@ from Acquisition import aq_acquire ...@@ -20,7 +20,7 @@ from Acquisition import aq_acquire
from App.config import getConfiguration from App.config import getConfiguration
from types import StringType, ListType from types import StringType, ListType
from zExceptions import Unauthorized 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 from ZODB.POSException import ConflictError
import transaction import transaction
import AccessControl.User import AccessControl.User
...@@ -142,20 +142,25 @@ def zpublisher_exception_hook(published, REQUEST, t, v, traceback): ...@@ -142,20 +142,25 @@ def zpublisher_exception_hook(published, REQUEST, t, v, traceback):
if t is SystemExit: if t is SystemExit:
raise raise
if issubclass(t, ConflictError): 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 global conflict_errors
conflict_errors = conflict_errors + 1 conflict_errors = conflict_errors + 1
method_name = REQUEST.get('PATH_INFO', '') method_name = REQUEST.get('PATH_INFO', '')
err = ('ZODB conflict error at %s ' LOG('ZODB', BLATHER, "%s at %s: %s"
'(%s conflicts since startup at %s)') " (%s conflicts since startup at %s)"
LOG(err % (method_name, conflict_errors, startup_time), % (v.__class__.__name__, method_name, v,
INFO, '') conflict_errors, startup_time),
LOG('Conflict traceback', BLATHER, '', error=sys.exc_info()) error=(t, v, traceback))
raise ZPublisher.Retry(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: try:
log = aq_acquire(published, '__error_log__', containment=1) log = aq_acquire(published, '__error_log__', containment=1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment