Commit 8c80c05b authored by Vincent Pelletier's avatar Vincent Pelletier

CMFActivity.Activity.SQLBase: Catch DatabaseError.

Fixes browsing ERP5 documents without activity tables available.
Of course, as most modifications trigger activity creation, no
modifications are possible. But this improves read-only access in
degraded conditions.
Also, by design a successful query must return one line, so do not test
returned value before processing it.
parent 7ac88028
...@@ -30,6 +30,7 @@ import sys ...@@ -30,6 +30,7 @@ import sys
import transaction import transaction
from DateTime import DateTime from DateTime import DateTime
from Shared.DC.ZRDB.Results import Results from Shared.DC.ZRDB.Results import Results
from Shared.DC.ZRDB.DA import DatabaseError
from zLOG import LOG, TRACE, INFO, WARNING, ERROR, PANIC from zLOG import LOG, TRACE, INFO, WARNING, ERROR, PANIC
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from Products.CMFActivity.ActivityTool import ( from Products.CMFActivity.ActivityTool import (
...@@ -216,9 +217,19 @@ class SQLBase(Queue): ...@@ -216,9 +217,19 @@ class SQLBase(Queue):
path = None path = None
else: else:
path = '/'.join(object.getPhysicalPath()) path = '/'.join(object.getPhysicalPath())
result = hasMessage(table=self.sql_table, path=path, method_id=method_id, try:
only_valid=only_valid, active_process_uid=active_process_uid) result = hasMessage(table=self.sql_table, path=path, method_id=method_id,
if result: only_valid=only_valid, active_process_uid=active_process_uid)
except DatabaseError:
LOG(
'SQLBase',
ERROR,
'%r raised, considering there are no activities' % (
hasMessage,
),
error=True,
)
else:
return result[0].message_count > 0 return result[0].message_count > 0
return 0 return 0
......
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