Commit c0fb8e54 authored by Vincent Pelletier's avatar Vincent Pelletier

all: Use zLOG.LOG(..., error=True) instead of immediate exc_info.

Simpler, and reduces the exposure of exc_info (which can be tricky to use
in other contexts).
parent 10a678e1
......@@ -37,8 +37,6 @@ from Products.ERP5Type.Cache import transactional_cached
# IMAP imports
import imaplib
import sys
# Transaction Management
from Shared.DC.ZRDB.TM import TM
......@@ -107,7 +105,7 @@ class IMAPSServer(MailServer):
self.server.logout()
except:
LOG('IMAPSServer', ERROR, "exception during _finish",
error=sys.exc_info())
error=True)
raise
def _abort(self, *ignored):
......@@ -123,7 +121,7 @@ class IMAPSServer(MailServer):
self.server.logout()
except:
LOG('IMAPSServer', ERROR, "exception during _abort",
error=sys.exc_info())
error=True)
raise
def _selectMessageFolder(self, message_folder):
......
......@@ -377,7 +377,7 @@ CREATE TABLE %s (
def _log(self, severity, summary):
LOG(self.__class__.__name__, severity, summary,
error=severity>INFO and sys.exc_info() or None)
error=severity > INFO)
def distribute(self, activity_tool, node_count):
db = activity_tool.getSQLConnection()
......
......@@ -25,7 +25,6 @@
from Shared.DC.ZRDB.TM import TM
from zLOG import LOG, ERROR
import sys
from collections import defaultdict
import transaction
......@@ -66,7 +65,7 @@ class ActivityBuffer(TM):
self.activity_tool = None
except:
LOG('ActivityBuffer', ERROR, "exception during _prepare",
error=sys.exc_info())
error=True)
raise
def deferredQueueMessage(self, activity_tool, activity, message):
......
......@@ -269,7 +269,7 @@ class Message(BaseMessage):
obj = self._getObject(activity_tool)
except KeyError:
LOG('CMFActivity', WARNING, "Message dropped (no object found at path %r)"
% (self.object_path,), error=sys.exc_info())
% (self.object_path,), error=True)
self.setExecutionState(MESSAGE_NOT_EXECUTABLE)
else:
if (self.oid and self.oid != getattr(aq_base(obj), '_p_oid', None) and
......@@ -1277,7 +1277,7 @@ class ActivityTool (BaseTool):
except:
# Catch ALL exception to avoid killing timerserver.
LOG('ActivityTool', ERROR, 'process_timer received an exception',
error=sys.exc_info())
error=True)
finally:
setSecurityManager(old_sm)
finally:
......
......@@ -59,7 +59,6 @@ from hashlib import md5
from warnings import warn
from cPickle import loads, dumps
from copy import deepcopy
from sys import exc_info
MYSQL_MIN_DATETIME_RESOLUTION = 1/86400.
......@@ -1400,7 +1399,7 @@ class SimulationTool(BaseTool):
except TypeError:
LOG("SimulationTool._getCachedInventoryList", WARNING,
"Failed copying sql_kw, disabling stock cache",
error=exc_info())
error=True)
raise StockOptimisationError
no_date_sql_kw, no_date_new_kw = self._generateKeywordDict(**no_date_kw)
no_date_stock_sql_kw = self._generateSQLKeywordDictFromKeywordDict(
......
......@@ -40,7 +40,6 @@ from Products.ERP5Type import Permissions
from Products.CMFCore.utils import getToolByName, _checkConditionalGET, _setCacheHeaders, _ViewEmulator
from OFS.Image import File as OFSFile
from warnings import warn
import sys
from base64 import decodestring
from Products.ERP5Type.UnrestrictedMethod import unrestricted_apply
from Products.ERP5.Document.Document import ConversionError, NotConvertedError
......@@ -125,7 +124,7 @@ class BaseExtensibleTraversableMixin(ExtensibleTraversableMixIn):
except:
LOG("ERP5 WARNING",0,
"Failed to retrieve user in __bobo_traverse__ of WebSection %s" % self.getPath(),
error=sys.exc_info())
error=True)
user = None
if user is not None and user.getUserName() == 'Anonymous User':
user = None # If the user which is connected is anonymous,
......
......@@ -51,7 +51,6 @@ from zExceptions import Forbidden
from Products.ERP5Type.PsycoWrapper import psyco
from Products.ERP5Type.Base import Base
import sys
class FieldValueCacheDict(dict):
_last_sync = -1
......@@ -237,7 +236,7 @@ class TALESValue(StaticValue):
# something reasonable rather than generate plenty of errors
LOG('ERP5Form', PROBLEM,
'Field.get_value %r [%s], exception on tales_expr: ' %
(field, id), error=sys.exc_info())
(field, id), error=True)
# field may be ProxyField
# here we avoid calling field.get_recursive_orig_value
# on all fields because it can be acquired from another
......
......@@ -27,7 +27,6 @@
#
##############################################################################
import sys
from AccessControl import ClassSecurityInfo
from AccessControl.ZopeGuards import guarded_getattr
from ZODB.POSException import ConflictError
......@@ -381,7 +380,7 @@ class MatrixBoxWidget(Widget.Widget):
except:
LOG('MatrixBox', WARNING, 'Could not evaluate the url '
'method %r with %r' % (url_method, cell),
error=sys.exc_info())
error=True)
else:
LOG('MatrixBox', WARNING,
'Could not find the url method %s' % (url_method_id,))
......
......@@ -28,8 +28,6 @@
#
##############################################################################
import sys
from Acquisition import Implicit
from Products.PythonScripts.Utility import allow_class
......@@ -243,7 +241,7 @@ class OOoParser(Implicit):
try:
oo_unzipped = ZipFile(file_descriptor, mode="r")
except Exception, e:
LOG('ERP5OOo', DEBUG, 'Error in openFile', error=sys.exc_info())
LOG('ERP5OOo', DEBUG, 'Error in openFile', error=True)
raise CorruptedOOoFile(e)
# Test the integrity of the file
if oo_unzipped.testzip() is not None:
......
......@@ -28,7 +28,6 @@ from Products.PluggableAuthService.interfaces.plugins import IUserEnumerationPlu
from Products.ERP5Type.Cache import CachingMethod, transactional_cached
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from ZODB.POSException import ConflictError
import sys
from DateTime import DateTime
from zLOG import LOG, PROBLEM
from Products import ERP5Security
......@@ -294,7 +293,7 @@ class ERP5UserManager(BasePlugin):
except ConflictError:
raise
except:
LOG('ERP5Security', PROBLEM, 'getUserByLogin failed', error=sys.exc_info())
LOG('ERP5Security', PROBLEM, 'getUserByLogin failed', error=True)
# Here we must raise an exception to prevent callers from caching
# a result of a degraded situation.
# The kind of exception does not matter as long as it's catched by
......
......@@ -74,7 +74,7 @@ for handler_id, module_id in handler_module_dict.iteritems():
LOG('ERP5TioSafe.__init__', WARNING,
'Unable to import module %r. %r transport will not be available.' % \
(module_id, handler_id),
error=sys.exc_info())
error=True)
else:
try:
registerConnectionPlugin(handler_id, getattr(module, module_id))
......@@ -82,4 +82,4 @@ for handler_id, module_id in handler_module_dict.iteritems():
LOG('ERP5TioSafe.ConnectionPlugin.__init__', WARNING,
'Unable to register module %r. error is %r.' % \
(module_id, msg),
error=sys.exc_info())
error=True)
......@@ -26,8 +26,6 @@
#
##############################################################################
import sys
from Products.CMFCore.Expression import Expression
from ZODB.POSException import ConflictError
......@@ -80,7 +78,7 @@ class TALESConstraint(Constraint):
raise
except Exception, e:
LOG('ERP5Type', PROBLEM, 'TALESConstraint error on "%s" on %s' %
(self.constraint_definition['expression'], obj), error=sys.exc_info())
(self.constraint_definition['expression'], obj), error=True)
error_list.append(self._generateError(obj,
self._getMessage('message_expression_error'),
mapping=dict(error_text=str(e))))
......
......@@ -27,8 +27,6 @@
#
##############################################################################
import sys
from Products.ERP5Type.mixin.constraint import ConstraintMixin
from Products.ERP5Type import PropertySheet
from zLOG import LOG, PROBLEM
......@@ -79,7 +77,7 @@ class TALESConstraint(ConstraintMixin):
raise
except Exception, e:
LOG('ERP5Type', PROBLEM, 'TALESConstraint error on "%s" on %s' %
(expression_text, obj), error=sys.exc_info())
(expression_text, obj), error=True)
return [self._generateError(obj,
self._getMessage('message_expression_error'),
......
......@@ -27,7 +27,6 @@
#
##############################################################################
import sys
from zLOG import LOG, WARNING
from AccessControl import ClassSecurityInfo
from Products.ERP5Type.Globals import InitializeClass, DTMLFile
......@@ -69,7 +68,7 @@ for handler_id, module_id in handler_module_dict.iteritems():
LOG('WebServiceTool', WARNING,
'Unable to import module %r. %r transport will not be available.' % \
(module_id, handler_id),
error=sys.exc_info())
error=True)
else:
registerConnectionPlugin(handler_id, getattr(module, module_id))
......
......@@ -1052,7 +1052,7 @@ def initializeLocalRegistry(directory_name, import_local_method):
raise
LOG('E5RP5Type', PROBLEM,
'Failed to add local %s to ERP5Type repository: %s (%s)'
% (directory_name, module_name, document_path), error=e)
% (directory_name, module_name, document_path), error=True)
def initializeLocalDocumentRegistry():
# XXX Arg are not consistent
......@@ -1368,7 +1368,7 @@ def assertAttributePortalType(o, attribute_name, portal_type):
o._delObject(attribute_name)
except (KeyError, AttributeError), err:
LOG('ERP5Type', PROBLEM, "assertAttributePortalType failed on %s" % o,
error=err)
error=True)
#####################################################
# Miscellaneous
......
# -*- coding: utf-8 -*-
import sys
from Products.ERP5Type import Permissions
from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter
from Products.ERP5Type.Globals import InitializeClass
......@@ -117,7 +115,7 @@ class GhostBaseMetaClass(ExtensionClass, AccessorHolderType):
raise
except Exception, e:
LOG('lazy_class.__getattribute__', WARNING, 'Failed to load class : %r' % (e,),
error=sys.exc_info())
error=True)
raise
return getattr(self, attr)
......@@ -353,7 +351,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
except AttributeError:
LOG("ERP5Type.Dynamic", WARNING,
"Could not access Portal Type Object for type %r"
% portal_type, error=sys.exc_info())
% portal_type, error=True)
base_tuple = (ERP5BaseBroken, )
portal_type_category_list = []
attribute_dict = dict(_categories=[], constraints=[])
......
......@@ -27,7 +27,6 @@
#
##############################################################################
import sys
import os
import inspect
import transaction
......@@ -441,7 +440,7 @@ def synchronizeDynamicModules(context, force=False):
# Required because the exception may be silently dropped by the caller.
transaction.doom()
LOG('ERP5Site', PANIC, "Automatic migration of core tools failed",
error=sys.exc_info())
error=True)
raise
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
......
......@@ -14,7 +14,6 @@
##############################################################################
# Stribger repair of BTreeFolder2
import sys
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
from Acquisition import aq_base
from BTrees.OOBTree import OOBTree
......@@ -72,7 +71,7 @@ def _cleanup(self):
except (AssertionError, KeyError):
LOG('BTreeFolder2', WARNING,
'Detected damage to %s. Fixing now.' % path,
error=sys.exc_info())
error=True)
try:
self._tree = OOBTree(self._tree)
mt_index = OOBTree()
......@@ -89,7 +88,7 @@ def _cleanup(self):
self._mt_index = OOBTree(mt_index)
except:
LOG('BTreeFolder2', ERROR, 'Failed to fix %s.' % path,
error=sys.exc_info())
error=True)
raise
else:
LOG('BTreeFolder2', INFO, 'Fixed %s.' % path)
......
......@@ -27,7 +27,6 @@ from Acquisition import aq_base, aq_parent
from zLOG import LOG, INFO, ERROR
from cStringIO import StringIO
from Products.ERP5Type import Permissions
import sys
security = ClassSecurityInfo()
DA.security = security
......@@ -224,7 +223,7 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
# LOG("DA query", INFO, "query = %s" %(query,))
result=DB__.query(query, self.max_rows_)
except:
LOG("DA call raise", ERROR, "DB = %s, c = %s, query = %s" %(DB__, c, query), error=sys.exc_info())
LOG("DA call raise", ERROR, "DB = %s, c = %s, query = %s" %(DB__, c, query), error=True)
raise
# patch: dynamic brain configuration
......
......@@ -13,7 +13,6 @@
#
##############################################################################
import sys
from zLOG import LOG, WARNING
from types import StringTypes
......@@ -565,7 +564,7 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False):
LOG('WorkflowTool.listActions', WARNING,
'Exception while computing worklists: %s'
% grouped_worklist_dict.keys(),
error=sys.exc_info())
error=True)
continue
except ProgrammingError, error_value:
# 1146 = table does not exist
......@@ -715,7 +714,7 @@ def WorkflowTool_refreshWorklistCache(self):
raise
LOG('WorkflowTool', WARNING, 'Insertion in worklist cache table ' \
'failed. Recreating table and retrying.',
error=sys.exc_info())
error=True)
self.Base_zCreateWorklistTable()
Base_zInsertIntoWorklistTable(**value_column_dict)
......
# -*- coding: utf-8 -*-
import base64, errno, logging, os, select, socket, sys, time
import errno, logging, os, socket, time
from threading import Thread
from UserDict import IterableUserDict
import Lifetime
......@@ -326,6 +326,6 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
try:
portal.portal_activities.process_timer(None, None)
except Exception:
LOG('Invoking Activity Tool', ERROR, '', error=sys.exc_info())
LOG('Invoking Activity Tool', ERROR, '', error=True)
except KeyboardInterrupt:
pass
......@@ -68,12 +68,11 @@ class Git(WorkingCopy):
try:
return subprocess.Popen(argv + list(args), **kw)
except OSError, e:
import sys
from zLOG import LOG, WARNING
LOG('Git', WARNING,
'will not work as the executable cannot be executed, perhaps not '
'in the Zope PATH or because of permissions.',
error=sys.exc_info())
error=True)
raise GitInstallationError("git command cannot be executed: %s" % \
e.strerror)
......
......@@ -32,7 +32,6 @@ from Acquisition import Implicit
import time
import os
import sys
from DateTime import DateTime
from Products.ERP5Type.Utils import convertToUpperCase
from MethodObject import Method
......@@ -413,6 +412,6 @@ except ImportError:
from zLOG import LOG, WARNING
LOG('Subversion', WARNING,
'could not import pysvn; until pysvn is installed properly,'
' this tool will not work.', error=sys.exc_info())
' this tool will not work.', error=True)
def newSubversionClient(container, **kw):
raise SubversionInstallationError, 'pysvn library is not installed'
......@@ -31,7 +31,6 @@ from Products.PluggableAuthService.interfaces.plugins import IUserEnumerationPlu
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Security.ERP5UserManager import ERP5UserManager
from ZODB.POSException import ConflictError
import sys
from DateTime import DateTime
from zLOG import LOG, PROBLEM
from AccessControl.AuthEncoding import pw_validate
......@@ -241,7 +240,7 @@ class EGOVUserManager(ERP5UserManager):
except ConflictError:
raise
except:
LOG('ERP5Security', PROBLEM, 'getUserByLogin failed', error=sys.exc_info())
LOG('ERP5Security', PROBLEM, 'getUserByLogin failed', error=True)
# Here we must raise an exception to prevent callers from caching
# a result of a degraded situation.
# The kind of exception does not matter as long as it's catched by
......
......@@ -12,7 +12,7 @@
#
##############################################################################
import operator, sys
import operator
from cgi import escape
from itertools import chain, imap, islice
from urllib import quote
......@@ -491,7 +491,7 @@ class HBTreeFolder2Base (Persistent):
raise
except Exception:
LOG('Zope', ERROR, 'manage_beforeDelete() threw',
error=sys.exc_info())
error=True)
self._delOb(id)
......
......@@ -255,7 +255,7 @@ class Localizer(LanguageManager, Folder):
def set(self, lang, priority):
if lang != self.lang:
LOG('Localizer', PROBLEM,
'Cannot change language inside a translationContext', error=1)
'Cannot change language inside a translationContext', error=True)
MARKER = []
from patches import get_request # late import, as this is patched by
# unit tests
......
......@@ -108,8 +108,6 @@ from DateTime import DateTime
from zLOG import LOG, ERROR, WARNING
from ZODB.POSException import ConflictError
import sys
hosed_connection = (
CR.SERVER_GONE_ERROR,
CR.SERVER_LOST
......@@ -438,7 +436,7 @@ class DB(TM):
self._query("SELECT GET_LOCK('%s',0)" % self._mysql_lock, allow_reconnect=not self._transactions)
except:
LOG('ZMySQLDA', ERROR, "exception during _begin",
error=sys.exc_info())
error=True)
raise
def tpc_vote(self, *ignored):
......@@ -477,7 +475,7 @@ class DB(TM):
LOG('ZMySQLDA', ERROR, "aborting when non-transactional")
except OperationalError, m:
LOG('ZMySQLDA', ERROR, "exception during _abort",
error=sys.exc_info())
error=True)
if m[0] not in hosed_connection:
raise
......
......@@ -28,7 +28,6 @@
#
##############################################################################
import sys
from SearchKey import SearchKey
from Products.ZSQLCatalog.Query.SimpleQuery import SimpleQuery
from Products.ZSQLCatalog.Query.ComplexQuery import ComplexQuery
......@@ -282,7 +281,7 @@ class DateTimeKey(SearchKey):
else:
subquery_list = matchExact(self, group, column, value_list, comparison_operator, logical_operator)
except DateTimeError:
LOG('DateTimeKey', 100, 'Got an exception while generating a query for %r %r.' % (comparison_operator, value_list), error=sys.exc_info())
LOG('DateTimeKey', 100, 'Got an exception while generating a query for %r %r.' % (comparison_operator, value_list), error=True)
else:
extend(subquery_list)
return query_list
......
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