[CMF-checkins] SVN: CMF/branches/1.6/C Got rid of zLOG in favor of
python's logging module.
Florent Guillaume
fg at nuxeo.com
Thu Jun 8 12:23:41 EDT 2006
Log message for revision 68523:
Got rid of zLOG in favor of python's logging module.
Changed:
U CMF/branches/1.6/CHANGES.txt
U CMF/branches/1.6/CMFCore/CMFCatalogAware.py
U CMF/branches/1.6/CMFCore/CatalogTool.py
U CMF/branches/1.6/CMFCore/CookieCrumbler.py
U CMF/branches/1.6/CMFCore/DirectoryView.py
U CMF/branches/1.6/CMFCore/FSMetadata.py
U CMF/branches/1.6/CMFCore/FSZSQLMethod.py
U CMF/branches/1.6/CMFCore/MembershipTool.py
U CMF/branches/1.6/CMFCore/Skinnable.py
U CMF/branches/1.6/CMFCore/TypesTool.py
U CMF/branches/1.6/CMFCore/tests/base/testcase.py
U CMF/branches/1.6/CMFCore/tests/test_CMFCatalogAware.py
U CMF/branches/1.6/CMFCore/tests/test_FSSecurity.py
U CMF/branches/1.6/CMFDefault/tests/test_Portal.py
U CMF/branches/1.6/CMFUid/UniqueIdHandlerTool.py
-=-
Modified: CMF/branches/1.6/CHANGES.txt
===================================================================
--- CMF/branches/1.6/CHANGES.txt 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CHANGES.txt 2006-06-08 16:23:41 UTC (rev 68523)
@@ -15,7 +15,9 @@
- IndexableObjectWrapper: Fixed list of provided interfaces.
The interfaces declared for the wrapped object are no longer masked.
+ - Got rid of zLOG in favor of python's logging module.
+
CMF 1.6.0 (2006/02/26)
Bug Fixes
Modified: CMF/branches/1.6/CMFCore/CMFCatalogAware.py
===================================================================
--- CMF/branches/1.6/CMFCore/CMFCatalogAware.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/CMFCatalogAware.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -15,7 +15,7 @@
$Id$
"""
-from zLOG import LOG, PROBLEM
+import logging
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from ExtensionClass import Base
@@ -31,6 +31,10 @@
from interfaces.IOpaqueItems import ICallableOpaqueItem
+
+logger = logging.getLogger('CMFCore.CMFCatalogAware')
+
+
class CMFCatalogAware(Base):
"""Mix-in for notifying portal_catalog and portal_workflow
"""
@@ -119,8 +123,8 @@
# BBB: Ignore old references to deleted objects.
# Can happen only in Zope 2.7, or when using
# catalog-getObject-raises off in Zope 2.8
- LOG('reindexObjectSecurity', PROBLEM,
- "Cannot get %s from catalog" % brain_path)
+ logger.warning("reindexObjectSecurity: Cannot get %s from "
+ "catalog", brain_path)
continue
# Recatalog with the same catalog uid.
s = getattr(ob, '_p_changed', 0)
Modified: CMF/branches/1.6/CMFCore/CatalogTool.py
===================================================================
--- CMF/branches/1.6/CMFCore/CatalogTool.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/CatalogTool.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -22,7 +22,6 @@
from DateTime import DateTime
from Globals import DTMLFile
from Globals import InitializeClass
-from Products.ZCatalog.ZCatalog import LOG
from Products.ZCatalog.ZCatalog import ZCatalog
from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
from Products.ZCTextIndex.Lexicon import CaseNormalizer
Modified: CMF/branches/1.6/CMFCore/CookieCrumbler.py
===================================================================
--- CMF/branches/1.6/CMFCore/CookieCrumbler.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/CookieCrumbler.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -25,7 +25,6 @@
from ZPublisher import BeforeTraverse
import Globals
from Globals import HTMLFile
-from zLOG import LOG, ERROR
from ZPublisher.HTTPRequest import HTTPRequest
from OFS.Folder import Folder
from zExceptions import Redirect
Modified: CMF/branches/1.6/CMFCore/DirectoryView.py
===================================================================
--- CMF/branches/1.6/CMFCore/DirectoryView.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/DirectoryView.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -19,6 +19,7 @@
from os import path, listdir, stat
from sys import exc_info
from sys import platform
+import logging
from warnings import warn
from AccessControl import ClassSecurityInfo
@@ -31,7 +32,6 @@
from Globals import Persistent
from OFS.Folder import Folder
from OFS.ObjectManager import bad_id
-from zLOG import LOG, ERROR
from zope.interface import implements
from FSMetadata import FSMetadata
@@ -45,6 +45,9 @@
from utils import normalize
+logger = logging.getLogger('CMFCore.DirectoryView')
+
+
def expandpath(p):
""" utils.expandpath() wrapper for backwards compatibility.
"""
@@ -152,10 +155,8 @@
path.walk(self._filepath, self._walker, filelist)
filelist.sort()
except:
- LOG('DirectoryView',
- ERROR,
- 'Error checking for directory modification',
- error=exc_info())
+ logger.error("Error checking for directory modification",
+ exc_info=True)
if mtime != self._v_last_read or filelist != self._v_last_filelist:
self._v_last_read = mtime
@@ -177,10 +178,7 @@
self.data, self.objects = self.prepareContents(registry,
register_subdirs=changed)
except:
- LOG('DirectoryView',
- ERROR,
- 'Error during prepareContents:',
- error=exc_info())
+ logger.error("Error during prepareContents", exc_info=True)
self.data = {}
self.objects = ()
@@ -252,8 +250,7 @@
exc_lines = traceback.format_exception( typ,
val,
tb )
- LOG( 'DirectoryView', ERROR,
- '\n'.join(exc_lines) )
+ logger.error('\n'.join(exc_lines))
ob = BadFile( name,
entry_minimal_fp,
@@ -270,20 +267,16 @@
try:
ob.manage_permission(name,roles,acquire)
except ValueError:
- LOG('DirectoryView',
- ERROR,
- 'Error setting permissions',
- error=exc_info())
+ logger.error("Error setting permissions",
+ exc_info=True)
# only DTML Methods and Python Scripts can have proxy roles
if hasattr(ob, '_proxy_roles'):
try:
ob._proxy_roles = tuple(metadata.getProxyRoles())
except:
- LOG('DirectoryView',
- ERROR,
- 'Error setting proxy role',
- error=exc_info())
+ logger.error("Error setting proxy role",
+ exc_info=True)
ob_id = ob.getId()
data[ob_id] = ob
Modified: CMF/branches/1.6/CMFCore/FSMetadata.py
===================================================================
--- CMF/branches/1.6/CMFCore/FSMetadata.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/FSMetadata.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -15,14 +15,17 @@
$Id$
"""
-from zLOG import LOG, ERROR
-from sys import exc_info
+import logging
from os.path import exists
from ConfigParser import ConfigParser
from warnings import warn
import re
+
+logger = logging.getLogger('CMFCore.FSMetadata')
+
+
class CMFConfigParser(ConfigParser):
""" This our wrapper around ConfigParser to
solve a few minor niggles with the code """
@@ -90,10 +93,7 @@
self._security = self._getSectionDict(cfg, 'security',
self._securityParser)
except:
- LOG('FSMetadata',
- ERROR,
- 'Error parsing .metadata file',
- error=exc_info())
+ logger.error("Error parsing .metadata file", exc_info=True)
# to add in a new value such as proxy roles,
# just add in the section, call it using getSectionDict
@@ -169,10 +169,8 @@
if len(kv) == 2:
props[kv[0].strip()] = kv[1].strip()
else:
- LOG('FSMetadata',
- ERROR,
- 'Error parsing .properties file',
- error=exc_info())
+ logger.error("Error parsing .properties file",
+ exc_info=True)
return props
@@ -207,10 +205,7 @@
if role:
roles.append(role)
except:
- LOG('DirectoryView',
- ERROR,
- 'Error reading permission from .security file',
- error=exc_info())
- # warning use of exc_info is deprecated
+ logger.error("Error reading permission from .security file",
+ exc_info=True)
prm[permission]=(acquire,roles)
return prm
Modified: CMF/branches/1.6/CMFCore/FSZSQLMethod.py
===================================================================
--- CMF/branches/1.6/CMFCore/FSZSQLMethod.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/FSZSQLMethod.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -15,11 +15,11 @@
$Id$
"""
+import logging
import Globals
from AccessControl import ClassSecurityInfo
from Acquisition import ImplicitAcquisitionWrapper
from Products.ZSQLMethods.SQL import SQL
-from zLOG import LOG, ERROR
from DirectoryView import registerFileExtension
from DirectoryView import registerMetaType
@@ -30,6 +30,9 @@
from utils import expandpath
+logger = logging.getLogger('CMFCore.FSZSQLMethod')
+
+
class FSZSQLMethod(SQL, FSObject):
"""FSZSQLMethods act like Z SQL Methods but are not directly
modifiable from the management interface."""
@@ -137,11 +140,7 @@
self._updateFromFS()
return self
except:
- import sys
- LOG('FS Z SQL Method',
- ERROR,
- 'Error during __of__',
- error=sys.exc_info())
+ logger.error("Error during __of__", exc_info=True)
raise
Globals.InitializeClass(FSZSQLMethod)
Modified: CMF/branches/1.6/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/1.6/CMFCore/MembershipTool.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/MembershipTool.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -15,6 +15,7 @@
$Id$
"""
+import logging
from AccessControl import ClassSecurityInfo
from AccessControl.User import nobody
from Acquisition import aq_base
@@ -46,6 +47,9 @@
from utils import UniqueObject
+logger = logging.getLogger('CMFCore.MembershipTool')
+
+
class MembershipTool(UniqueObject, Folder, ActionProviderBase):
""" This tool accesses member data through an acl_users object.
@@ -142,13 +146,7 @@
except ConflictError:
raise
except:
- from zLOG import LOG, ERROR
- import sys
- LOG('CMFCore.MembershipTool',
- ERROR,
- 'Error during wrapUser',
- error=sys.exc_info(),
- )
+ logger.error("Error during wrapUser", exc_info=True)
return u
security.declareProtected(ManagePortal, 'getPortalRoles')
Modified: CMF/branches/1.6/CMFCore/Skinnable.py
===================================================================
--- CMF/branches/1.6/CMFCore/Skinnable.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/Skinnable.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -18,6 +18,7 @@
$Id$
"""
+import logging
from thread import get_ident
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
@@ -27,6 +28,9 @@
from ZODB.POSException import ConflictError
+logger = logging.getLogger('CMFCore.Skinnable')
+
+
# superGetAttr is assigned to whatever ObjectManager.__getattr__
# used to do.
try:
@@ -189,10 +193,7 @@
except:
# This shouldn't happen, even if the requested skin
# does not exist.
- import sys
- from zLOG import LOG, ERROR
- LOG('CMFCore', ERROR, 'Unable to setupCurrentSkin()',
- error=sys.exc_info())
+ logger.error("Unable to setupCurrentSkin()", exc_info=True)
return w_self
def _checkId(self, id, allow_dup=0):
Modified: CMF/branches/1.6/CMFCore/TypesTool.py
===================================================================
--- CMF/branches/1.6/CMFCore/TypesTool.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/TypesTool.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -15,8 +15,8 @@
$Id$
"""
-from sys import exc_info
from warnings import warn
+import logging
from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager
@@ -27,7 +27,6 @@
from OFS.Folder import Folder
from OFS.ObjectManager import IFAwareObjectManager
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from zLOG import LOG, ERROR
import Products
from ActionProviderBase import ActionProviderBase
@@ -53,6 +52,9 @@
from zope.interface import implements
+logger = logging.getLogger('CMFCore.TypesTool')
+
+
_marker = [] # Create a new marker.
@@ -524,8 +526,8 @@
try:
p = dispatcher[self.product]
except AttributeError:
- LOG('Types Tool', ERROR, '_queryFactoryMethod raised an exception',
- error=exc_info())
+ logger.error("_queryFactoryMethod raised an exception",
+ exc_info=True)
return default
m = getattr(p, self.factory, None)
Modified: CMF/branches/1.6/CMFCore/tests/base/testcase.py
===================================================================
--- CMF/branches/1.6/CMFCore/tests/base/testcase.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/tests/base/testcase.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -4,6 +4,7 @@
import sys
import time
+import logging
from os import chmod, curdir, mkdir, remove, stat, walk
from os.path import join, abspath, dirname
from shutil import copytree, rmtree
@@ -14,7 +15,6 @@
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from Testing.makerequest import makerequest
-import zLOG
import transaction
from dummy import DummyFolder
@@ -54,32 +54,38 @@
class LogInterceptor:
- _old_log_write = None
logged = None
+ installed = ()
+ level = 0
- def _catch_log_errors( self, ignored_level=zLOG.PROBLEM ):
+ def _catch_log_errors(self, ignored_level=logging.WARNING, subsystem=''):
- if self._old_log_write is not None:
- return
+ if subsystem in self.installed:
+ raise ValueError, 'Already installed filter!'
- def log_write(subsystem, severity, summary, detail, error):
- if severity > ignored_level:
- assert 0, "%s(%s): %s" % (subsystem, severity, summary)
- if self.logged is None:
- self.logged = []
- self.logged.append( ( subsystem, severity, summary, detail ) )
+ root_logger = logging.getLogger(subsystem)
+ self.installed += (subsystem,)
+ self.level = ignored_level
+ root_logger.addFilter(self)
- self._old_log_write = zLOG.log_write
- zLOG.log_write = log_write
+ def filter(self, record):
+ if record.levelno > self.level:
+ return True
+ if self.logged is None:
+ self.logged = []
+ self.logged.append(record)
+ return False
- def _ignore_log_errors( self ):
+ def _ignore_log_errors(self, subsystem=''):
- if self._old_log_write is None:
+ if subsystem not in self.installed:
return
- zLOG.log_write = self._old_log_write
- del self._old_log_write
+ root_logger = logging.getLogger(subsystem)
+ root_logger.removeFilter(self)
+ self.installed = tuple([s for s in self.installed if s != subsystem])
+
class WarningInterceptor:
_old_stderr = None
Modified: CMF/branches/1.6/CMFCore/tests/test_CMFCatalogAware.py
===================================================================
--- CMF/branches/1.6/CMFCore/tests/test_CMFCatalogAware.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/tests/test_CMFCatalogAware.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -112,6 +112,7 @@
def tearDown(self):
self._ignore_log_errors()
+ self._ignore_log_errors(subsystem='CMFCore.CMFCatalogAware')
def test_indexObject(self):
foo = self.site.foo
@@ -193,7 +194,7 @@
def test_reindexObjectSecurity_missing_noraise(self):
# Raising disabled
- self._catch_log_errors()
+ self._catch_log_errors(subsystem='CMFCore.CMFCatalogAware')
foo = self.site.foo
missing = TheClass('missing').__of__(foo)
missing.GETOBJECT_RAISES = False
@@ -207,7 +208,7 @@
def test_reindexObjectSecurity_missing_oldbrain(self):
# Missing object is swallowed by old Zope brains
- self._catch_log_errors()
+ self._catch_log_errors(subsystem='CMFCore.CMFCatalogAware')
self.site.portal_catalog.brain_class = DummyOldBrain
foo = self.site.foo
missing = TheClass('missing').__of__(foo)
Modified: CMF/branches/1.6/CMFCore/tests/test_FSSecurity.py
===================================================================
--- CMF/branches/1.6/CMFCore/tests/test_FSSecurity.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFCore/tests/test_FSSecurity.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -56,6 +56,7 @@
RequestTest.tearDown(self)
FSDVTest.tearDown(self)
self._ignore_log_errors()
+ self._ignore_log_errors(subsystem='CMFCore.DirectoryView')
class FSSecurityTests( FSSecurityBase, LogInterceptor ):
@@ -69,8 +70,8 @@
self._checkSettings(self.ob.fake_skin.test4,'Access contents information',0,[])
def test_invalidPermissionNames( self ):
- import zLOG
- self._catch_log_errors(zLOG.ERROR)
+ import logging
+ self._catch_log_errors(logging.ERROR,subsystem='CMFCore.DirectoryView')
# Test for an invalid permission name
# baseline
self._checkSettings(self.ob.fake_skin.test5,'View',1,[])
Modified: CMF/branches/1.6/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_Portal.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFDefault/tests/test_Portal.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -39,8 +39,10 @@
SecurityRequestTest.setUp( self )
self._trap_warning_output()
zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('permissions.zcml', Products.Five)
zcml.load_config('configure.zcml', Products.GenericSetup)
zcml.load_config('configure.zcml', Products.CMFCore)
+ zcml.load_config('configure.zcml', Products.DCWorkflow)
def tearDown( self ):
self._free_warning_output()
@@ -64,19 +66,6 @@
return content
- def setUp(self):
- PlacelessSetup.setUp(self)
- SecurityRequestTest.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.GenericSetup)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
-
- def tearDown(self):
- SecurityRequestTest.tearDown(self)
- PlacelessSetup.tearDown(self)
-
def test_new( self ):
site = self._makeSite()
Modified: CMF/branches/1.6/CMFUid/UniqueIdHandlerTool.py
===================================================================
--- CMF/branches/1.6/CMFUid/UniqueIdHandlerTool.py 2006-06-08 15:31:53 UTC (rev 68522)
+++ CMF/branches/1.6/CMFUid/UniqueIdHandlerTool.py 2006-06-08 16:23:41 UTC (rev 68523)
@@ -18,10 +18,10 @@
"""
import os
+import logging
import Missing
-import zLOG
from Globals import InitializeClass
from Globals import package_home
from AccessControl import ClassSecurityInfo
@@ -191,9 +191,8 @@
# print a message to the log if more than one object has
# the same uid (uups!)
if len_result > 1:
- zLOG.LOG("CMUid ASSERT:", zLOG.INFO,
- "Uups, %s objects have '%s' as uid!!!" % \
- (len_result, uid))
+ logging.getLogger('CMFUid').error(
+ "ASSERT: %d objects have %r as uid!!!", len_result, uid)
return result[0]
More information about the CMF-checkins
mailing list