Commit e6327ae3 authored by Tres Seaver's avatar Tres Seaver

Sync with 2.9 branch.

parent 744676b1
...@@ -18,6 +18,8 @@ Zope Changes ...@@ -18,6 +18,8 @@ Zope Changes
Bugs fixed Bugs fixed
- Collector #2113: 'zopectl test' often masked Ctrl-C.
- OFS Application: Updated deprecation warnings. - OFS Application: Updated deprecation warnings.
Support for '__ac_permissions__' and 'meta_types' will be removed in Support for '__ac_permissions__' and 'meta_types' will be removed in
Zope 2.11, 'methods' support might remain longer. Zope 2.11, 'methods' support might remain longer.
......
...@@ -15,13 +15,15 @@ ...@@ -15,13 +15,15 @@
import os import os
import string import string
import logging
logger = logging.getLogger('Zope Security Policy')
from Acquisition import aq_base from Acquisition import aq_base
from Acquisition import aq_parent from Acquisition import aq_parent
from Acquisition import aq_inner from Acquisition import aq_inner
from Acquisition import aq_acquire from Acquisition import aq_acquire
from ExtensionClass import Base from ExtensionClass import Base
from zLOG import LOG, BLATHER, PROBLEM from zLOG.EventLogger import CUSTOM_BLATHER
from zope.interface import implements from zope.interface import implements
# This is used when a permission maps explicitly to no permission. We # This is used when a permission maps explicitly to no permission. We
...@@ -346,8 +348,8 @@ class ZopeSecurityPolicy: ...@@ -346,8 +348,8 @@ class ZopeSecurityPolicy:
return 1 return 1
except TypeError: except TypeError:
# 'roles' isn't a sequence # 'roles' isn't a sequence
LOG('Zope Security Policy', PROBLEM, "'%s' passed as roles" logger.warn("'%s' passed as roles"
" during validation of '%s' is not a sequence." % ( " during validation of '%s' is not a sequence." % (
`roles`, name)) `roles`, name))
raise raise
...@@ -804,7 +806,7 @@ def raiseVerbose(msg, accessed, container, name, value, context, ...@@ -804,7 +806,7 @@ def raiseVerbose(msg, accessed, container, name, value, context,
info.append(s + '.') info.append(s + '.')
text = ' '.join(info) text = ' '.join(info)
LOG('Zope Security Policy', BLATHER, 'Unauthorized: %s' % text) logger.log(CUSTOM_BLATHER, 'Unauthorized: %s' % text)
raise Unauthorized(text) raise Unauthorized(text)
def getUserRolesInContext(user, context): def getUserRolesInContext(user, context):
......
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
""" """
import sys import sys
import logging
logger = logging.getLogger('SecurityInfo')
import Acquisition import Acquisition
from AccessControl.ImplPython import _what_not_even_god_should_do from AccessControl.ImplPython import _what_not_even_god_should_do
from zLOG import LOG, WARNING
# Security constants - these are imported into the AccessControl # Security constants - these are imported into the AccessControl
# namespace and can be referenced as AccessControl.PUBLIC etc. # namespace and can be referenced as AccessControl.PUBLIC etc.
...@@ -69,8 +69,8 @@ class SecurityInfo(Acquisition.Implicit): ...@@ -69,8 +69,8 @@ class SecurityInfo(Acquisition.Implicit):
def _setaccess(self, names, access): def _setaccess(self, names, access):
for name in names: for name in names:
if self.names.get(name, access) != access: if self.names.get(name, access) != access:
LOG('SecurityInfo', WARNING, 'Conflicting security ' logger.warn('Conflicting security declarations for "%s"'
'declarations for "%s"' % name) % name)
self._warnings = 1 self._warnings = 1
self.names[name] = access self.names[name] = access
...@@ -111,8 +111,8 @@ class SecurityInfo(Acquisition.Implicit): ...@@ -111,8 +111,8 @@ class SecurityInfo(Acquisition.Implicit):
for role in roles: for role in roles:
rdict[role] = 1 rdict[role] = 1
if self.roles.get(permission_name, rdict) != rdict: if self.roles.get(permission_name, rdict) != rdict:
LOG('SecurityInfo', WARNING, 'Conflicting default role' logger.warn('Conflicting default role '
'declarations for permission "%s"' % permission_name) 'declarations for permission "%s"' % permission_name)
self._warnings = 1 self._warnings = 1
self.roles[permission_name] = rdict self.roles[permission_name] = rdict
...@@ -193,8 +193,8 @@ class ClassSecurityInfo(SecurityInfo): ...@@ -193,8 +193,8 @@ class ClassSecurityInfo(SecurityInfo):
access) access)
if getattr(self, '_warnings', None): if getattr(self, '_warnings', None):
LOG('SecurityInfo', WARNING, 'Class "%s" had conflicting ' logger.warn('Class "%s" had conflicting security declarations'
'security declarations' % classobj.__name__) % classobj.__name__)
class ClassSecurityInformation(ClassSecurityInfo): class ClassSecurityInformation(ClassSecurityInfo):
# Default policy is disallow # Default policy is disallow
...@@ -273,8 +273,8 @@ class _ModuleSecurityInfo(SecurityInfo): ...@@ -273,8 +273,8 @@ class _ModuleSecurityInfo(SecurityInfo):
dict['__allow_access_to_unprotected_subobjects__'] = self dict['__allow_access_to_unprotected_subobjects__'] = self
if getattr(self, '_warnings', None): if getattr(self, '_warnings', None):
LOG('SecurityInfo', WARNING, 'Module "%s" had conflicting ' logger.warn('Module "%s" had conflicting security declarations'
'security declarations' % dict['__name__']) % dict['__name__'])
declareProtected__roles__=ACCESS_PRIVATE declareProtected__roles__=ACCESS_PRIVATE
def declareProtected(self, permission_name, *names): def declareProtected(self, permission_name, *names):
......
...@@ -15,6 +15,9 @@ __doc__="""System management components""" ...@@ -15,6 +15,9 @@ __doc__="""System management components"""
__version__='$Revision: 1.94 $'[11:-2] __version__='$Revision: 1.94 $'[11:-2]
import sys,os,time,Globals, Acquisition, os, Undo import sys,os,time,Globals, Acquisition, os, Undo
import logging
logger = logging.getLogger('ApplicationManager')
from Globals import DTMLFile from Globals import DTMLFile
from OFS.ObjectManager import ObjectManager from OFS.ObjectManager import ObjectManager
from OFS.Folder import Folder from OFS.Folder import Folder
...@@ -31,7 +34,6 @@ from AccessControl import getSecurityManager ...@@ -31,7 +34,6 @@ from AccessControl import getSecurityManager
from zExceptions import Redirect from zExceptions import Redirect
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from cgi import escape from cgi import escape
import zLOG
import Lifetime import Lifetime
try: import thread try: import thread
...@@ -391,8 +393,7 @@ class ApplicationManager(Folder,CacheManager): ...@@ -391,8 +393,7 @@ class ApplicationManager(Folder,CacheManager):
user = '"%s"' % getSecurityManager().getUser().getUserName() user = '"%s"' % getSecurityManager().getUser().getUserName()
except: except:
user = 'unknown user' user = 'unknown user'
zLOG.LOG("ApplicationManager", zLOG.INFO, logger.info("Restart requested by %s" % user)
"Restart requested by %s" % user)
#for db in Globals.opened: db.close() #for db in Globals.opened: db.close()
Lifetime.shutdown(1) Lifetime.shutdown(1)
return """<html> return """<html>
...@@ -407,8 +408,7 @@ class ApplicationManager(Folder,CacheManager): ...@@ -407,8 +408,7 @@ class ApplicationManager(Folder,CacheManager):
user = '"%s"' % getSecurityManager().getUser().getUserName() user = '"%s"' % getSecurityManager().getUser().getUserName()
except: except:
user = 'unknown user' user = 'unknown user'
zLOG.LOG("ApplicationManager", zLOG.INFO, logger.info("Shutdown requested by %s" % user)
"Shutdown requested by %s" % user)
#for db in Globals.opened: db.close() #for db in Globals.opened: db.close()
Lifetime.shutdown(0) Lifetime.shutdown(0)
return """<html> return """<html>
......
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
# #
############################################################################## ##############################################################################
import logging
logger = logging.getLogger('Hotfixes')
from version_txt import getZopeVersion from version_txt import getZopeVersion
from zLOG import LOG, INFO, WARNING
merged_hotfixes = { merged_hotfixes = {
'Hotfix_2001-09-28': 1, 'Hotfix_2001-09-28': 1,
...@@ -33,13 +35,13 @@ def isMerged(name): ...@@ -33,13 +35,13 @@ def isMerged(name):
def logHotfix(id, apply_hotfix): def logHotfix(id, apply_hotfix):
if apply_hotfix: if apply_hotfix:
LOG('Hotfixes', INFO, 'Applying %s' % id) logger.info('Applying %s' % id)
elif apply_hotfix is OUTDATED_ZOPE: elif apply_hotfix is OUTDATED_ZOPE:
LOG('Hotfixes', WARNING, 'Not applying %s. It is not designed for ' logger.warn('Not applying %s. It is not designed for '
'this version of Zope. Please uninstall the hotfix product.' 'this version of Zope. Please uninstall the hotfix product.'
% id) % id)
else: # ALREADY_MERGED else: # ALREADY_MERGED
LOG('Hotfixes', WARNING, 'Not applying %s. The fix has already been ' logger.warn('Not applying %s. The fix has already been '
'merged into Zope. Please uninstall the hotfix product.' 'merged into Zope. Please uninstall the hotfix product.'
% id) % id)
......
...@@ -17,6 +17,8 @@ $Id$ ...@@ -17,6 +17,8 @@ $Id$
import os.path, re import os.path, re
import stat import stat
import logging
logger = logging.getLogger('Zope')
from AccessControl.PermissionRole import PermissionRole from AccessControl.PermissionRole import PermissionRole
import Globals, os, OFS.ObjectManager, OFS.misc_, Products import Globals, os, OFS.ObjectManager, OFS.misc_, Products
...@@ -25,7 +27,6 @@ from App.Product import doInstall ...@@ -25,7 +27,6 @@ from App.Product import doInstall
from HelpSys import HelpTopic, APIHelpTopic from HelpSys import HelpTopic, APIHelpTopic
from HelpSys.HelpSys import ProductHelp from HelpSys.HelpSys import ProductHelp
from FactoryDispatcher import FactoryDispatcher from FactoryDispatcher import FactoryDispatcher
from zLOG import LOG, WARNING
from DateTime import DateTime from DateTime import DateTime
from Interface.Implements import instancesOfObjectImplements from Interface.Implements import instancesOfObjectImplements
from zope.interface import implementedBy from zope.interface import implementedBy
...@@ -312,7 +313,7 @@ class ProductContext: ...@@ -312,7 +313,7 @@ class ProductContext:
try: try:
dir_mod_time=DateTime(os.stat(path)[stat.ST_MTIME]) dir_mod_time=DateTime(os.stat(path)[stat.ST_MTIME])
except OSError, (errno, text): except OSError, (errno, text):
LOG("Zope", WARNING, '%s: %s' % (text, path)) logger.warn('%s: %s' % (text, path))
return return
# test to see if nothing has changed since last registration # test to see if nothing has changed since last registration
......
...@@ -17,11 +17,14 @@ $Id$ ...@@ -17,11 +17,14 @@ $Id$
import os, sys import os, sys
from time import time from time import time
from traceback import format_exception
import logging
logger = logging.getLogger('Refresh')
import transaction import transaction
import Products import Products
from ExtensionClass import Base from ExtensionClass import Base
from Globals import PersistentMapping from Globals import PersistentMapping
from zLOG import format_exception, LOG, ERROR, INFO
global_classes_timestamp = 0 global_classes_timestamp = 0
products_mod_times = {} products_mod_times = {}
...@@ -136,8 +139,8 @@ def listRefreshableModules(productid): ...@@ -136,8 +139,8 @@ def listRefreshableModules(productid):
def logBadRefresh(productid): def logBadRefresh(productid):
exc = sys.exc_info() exc = sys.exc_info()
try: try:
LOG('Refresh', ERROR, 'Exception while refreshing %s' logger.error('Exception while refreshing %s'
% productid, error=exc) % productid, error=exc)
if hasattr(exc[0], '__name__'): if hasattr(exc[0], '__name__'):
error_type = exc[0].__name__ error_type = exc[0].__name__
else: else:
...@@ -179,7 +182,7 @@ def performRefresh(jar, productid): ...@@ -179,7 +182,7 @@ def performRefresh(jar, productid):
def performSafeRefresh(jar, productid): def performSafeRefresh(jar, productid):
try: try:
LOG('Refresh', INFO, 'Refreshing product %s' % productid) logger.info('Refreshing product %s' % productid)
if not performRefresh(jar, productid): if not performRefresh(jar, productid):
return 0 return 0
except: except:
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
from types import InstanceType
import logging
logger = logging.getLogger('ZPublisher')
import DocumentTemplate, Common, Persistence, MethodObject, Globals, os, sys import DocumentTemplate, Common, Persistence, MethodObject, Globals, os, sys
from types import InstanceType
from zLOG import LOG,WARNING
from App.config import getConfiguration from App.config import getConfiguration
class HTML(DocumentTemplate.HTML,Persistence.Persistent,): class HTML(DocumentTemplate.HTML,Persistence.Persistent,):
...@@ -175,8 +176,10 @@ class DTMLFile(Bindings, Explicit, ClassicHTMLFile): ...@@ -175,8 +176,10 @@ class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
try: result = render_blocks(self._v_blocks, ns) try: result = render_blocks(self._v_blocks, ns)
except DTReturn, v: result = v.v except DTReturn, v: result = v.v
except AttributeError: except AttributeError:
if type(sys.exc_value)==InstanceType and sys.exc_value.args[0]=="_v_blocks": if (type(sys.exc_value) == InstanceType
LOG("ZPublisher",WARNING,"DTML file '%s' could not be read" % self.raw) and sys.exc_value.args[0]=="_v_blocks"):
logger.warn("DTML file '%s' could not be read"
% self.raw)
raise ValueError, ("DTML file error: " raise ValueError, ("DTML file error: "
"Check logfile for details") "Check logfile for details")
else: else:
......
...@@ -15,10 +15,12 @@ ...@@ -15,10 +15,12 @@
$Id$ $Id$
""" """
import time, sys import time, sys
import logging
logger = logging.getLogger('Cache')
import Globals import Globals
from Globals import DTMLFile from Globals import DTMLFile
from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base
from zLOG import LOG, WARNING
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.Role import _isBeingUsedAsAMethod from AccessControl.Role import _isBeingUsedAsAMethod
from AccessControl import Unauthorized from AccessControl import Unauthorized
...@@ -195,8 +197,7 @@ class Cacheable: ...@@ -195,8 +197,7 @@ class Cacheable:
mtime_func, default) mtime_func, default)
return val return val
except: except:
LOG('Cache', WARNING, 'ZCache_get() exception', logger.warn('ZCache_get() exception', error=sys.exc_info())
error=sys.exc_info())
return default return default
return default return default
...@@ -213,8 +214,7 @@ class Cacheable: ...@@ -213,8 +214,7 @@ class Cacheable:
c.ZCache_set(ob, data, view_name, keywords, c.ZCache_set(ob, data, view_name, keywords,
mtime_func) mtime_func)
except: except:
LOG('Cache', WARNING, 'ZCache_set() exception', logger.warn('ZCache_set() exception', error=sys.exc_info())
error=sys.exc_info())
def ZCacheable_invalidate(self, view_name='', REQUEST=None): def ZCacheable_invalidate(self, view_name='', REQUEST=None):
'''Called after a cacheable object is edited. Causes all '''Called after a cacheable object is edited. Causes all
...@@ -231,8 +231,7 @@ class Cacheable: ...@@ -231,8 +231,7 @@ class Cacheable:
except: except:
exc = sys.exc_info() exc = sys.exc_info()
try: try:
LOG('Cache', WARNING, 'ZCache_invalidate() exception', logger.warn('ZCache_invalidate() exception', error=exc)
error=exc)
message = 'An exception occurred: %s: %s' % exc[:2] message = 'An exception occurred: %s: %s' % exc[:2]
finally: finally:
exc = None exc = None
......
...@@ -20,6 +20,8 @@ import marshal ...@@ -20,6 +20,8 @@ import marshal
import sys, fnmatch, copy, os, re import sys, fnmatch, copy, os, re
from cgi import escape from cgi import escape
from cStringIO import StringIO from cStringIO import StringIO
import logging
logger = logging.getLogger('FTP')
from types import StringType, UnicodeType from types import StringType, UnicodeType
import App.Common import App.Common
...@@ -36,7 +38,6 @@ from webdav.Collection import Collection ...@@ -36,7 +38,6 @@ from webdav.Collection import Collection
from webdav.Lockable import ResourceLockedError from webdav.Lockable import ResourceLockedError
from webdav.NullResource import NullResource from webdav.NullResource import NullResource
from zExceptions import BadRequest from zExceptions import BadRequest
from zLOG import LOG, ERROR
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from zope.interface import implements from zope.interface import implements
...@@ -673,8 +674,8 @@ class ObjectManager( ...@@ -673,8 +674,8 @@ class ObjectManager(
try: try:
stat=marshal.loads(v.manage_FTPstat(REQUEST)) stat=marshal.loads(v.manage_FTPstat(REQUEST))
except: except:
LOG("FTP", ERROR, "Failed to stat file '%s'" % k, logger.error("Failed to stat file '%s'" % k,
error=sys.exc_info()) error=sys.exc_info())
stat=None stat=None
if stat is not None: if stat is not None:
out=out+((k,stat),) out=out+((k,stat),)
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
""" """
Objects for packages that have been uninstalled. Objects for packages that have been uninstalled.
""" """
import SimpleItem, Globals, Acquisition from thread import allocate_lock
import logging
logger = logging.getLogger('ZODB') # ???
import SimpleItem, Globals, Acquisition
from Acquisition import Acquired from Acquisition import Acquired
import Persistence import Persistence
from thread import allocate_lock
from zLOG import LOG, WARNING
from cgi import escape from cgi import escape
broken_klasses={} broken_klasses={}
...@@ -71,8 +73,9 @@ def Broken(self, oid, pair): ...@@ -71,8 +73,9 @@ def Broken(self, oid, pair):
klass.info=( klass.info=(
'This object\'s class was %s in module %s.' % 'This object\'s class was %s in module %s.' %
(klass.__name__, klass.__module__)) (klass.__name__, klass.__module__))
LOG('ZODB', WARNING, 'Could not import class %s ' logger.warn('Could not import class %s '
'from module %s' % (`klass.__name__`, `klass.__module__`)) 'from module %s'
% (`klass.__name__`, `klass.__module__`))
finally: finally:
broken_klasses_lock.release() broken_klasses_lock.release()
if oid is None: return klass if oid is None: return klass
......
...@@ -17,6 +17,7 @@ $Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $ ...@@ -17,6 +17,7 @@ $Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $
""" """
import sys import sys
import logging
from cgi import escape from cgi import escape
from urllib import quote from urllib import quote
from random import randint from random import randint
...@@ -35,7 +36,6 @@ from OFS.Folder import Folder ...@@ -35,7 +36,6 @@ from OFS.Folder import Folder
from AccessControl import getSecurityManager, ClassSecurityInfo from AccessControl import getSecurityManager, ClassSecurityInfo
from AccessControl.Permissions import access_contents_information, \ from AccessControl.Permissions import access_contents_information, \
view_management_screens view_management_screens
from zLOG import LOG, INFO, ERROR, WARNING
from Products.ZCatalog.Lazy import LazyMap from Products.ZCatalog.Lazy import LazyMap
from zope.event import notify from zope.event import notify
from zope.app.container.contained import ObjectAddedEvent from zope.app.container.contained import ObjectAddedEvent
...@@ -45,6 +45,7 @@ from OFS.event import ObjectWillBeAddedEvent ...@@ -45,6 +45,7 @@ from OFS.event import ObjectWillBeAddedEvent
from OFS.event import ObjectWillBeRemovedEvent from OFS.event import ObjectWillBeRemovedEvent
import OFS.subscribers import OFS.subscribers
LOG = logging.getLogger('BTreeFolder2')
manage_addBTreeFolderForm = DTMLFile('folderAdd', globals()) manage_addBTreeFolderForm = DTMLFile('folderAdd', globals())
...@@ -191,8 +192,7 @@ class BTreeFolder2Base (Persistent): ...@@ -191,8 +192,7 @@ class BTreeFolder2Base (Persistent):
% repr(key)) % repr(key))
return 1 return 1
except AssertionError: except AssertionError:
LOG('BTreeFolder2', WARNING, LOG.warn( 'Detected damage to %s. Fixing now.' % path,
'Detected damage to %s. Fixing now.' % path,
error=sys.exc_info()) error=sys.exc_info())
try: try:
self._tree = OOBTree(self._tree) self._tree = OOBTree(self._tree)
...@@ -201,11 +201,11 @@ class BTreeFolder2Base (Persistent): ...@@ -201,11 +201,11 @@ class BTreeFolder2Base (Persistent):
mt_index[key] = OIBTree(value) mt_index[key] = OIBTree(value)
self._mt_index = mt_index self._mt_index = mt_index
except: except:
LOG('BTreeFolder2', ERROR, 'Failed to fix %s.' % path, LOG.error('Failed to fix %s.' % path,
error=sys.exc_info()) error=sys.exc_info())
raise raise
else: else:
LOG('BTreeFolder2', INFO, 'Fixed %s.' % path) LOG.info('Fixed %s.' % path)
return 0 return 0
......
...@@ -18,8 +18,9 @@ Zope object encapsulating a Page Template from the filesystem. ...@@ -18,8 +18,9 @@ Zope object encapsulating a Page Template from the filesystem.
__version__ = '$Revision: 1.30 $'[11:-2] __version__ = '$Revision: 1.30 $'[11:-2]
import os, AccessControl import os, AccessControl
import logging
from Globals import package_home, DevelopmentMode from Globals import package_home, DevelopmentMode
from zLOG import LOG, ERROR
from Shared.DC.Scripts.Script import Script from Shared.DC.Scripts.Script import Script
from Shared.DC.Scripts.Signature import FuncCode from Shared.DC.Scripts.Signature import FuncCode
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
...@@ -31,6 +32,8 @@ from Acquisition import aq_parent, aq_inner ...@@ -31,6 +32,8 @@ from Acquisition import aq_parent, aq_inner
from App.config import getConfiguration from App.config import getConfiguration
from OFS.SimpleItem import Item_w__name__ from OFS.SimpleItem import Item_w__name__
LOG = logging.getLogger('PageTemplateFile')
class PageTemplateFile(Item_w__name__, Script, PageTemplate, Traversable): class PageTemplateFile(Item_w__name__, Script, PageTemplate, Traversable):
"Zope wrapper for filesystem Page Template using TAL, TALES, and METAL" "Zope wrapper for filesystem Page Template using TAL, TALES, and METAL"
...@@ -146,8 +149,7 @@ class PageTemplateFile(Item_w__name__, Script, PageTemplate, Traversable): ...@@ -146,8 +149,7 @@ class PageTemplateFile(Item_w__name__, Script, PageTemplate, Traversable):
self.pt_edit(text, t) self.pt_edit(text, t)
self._cook() self._cook()
if self._v_errors: if self._v_errors:
LOG('PageTemplateFile', ERROR, 'Error in template', LOG.error('Error in template', '\n'.join(self._v_errors))
'\n'.join(self._v_errors))
return return
self._v_last_read = mtime self._v_last_read = mtime
......
...@@ -20,7 +20,6 @@ __version__='$Revision: 1.48 $'[11:-2] ...@@ -20,7 +20,6 @@ __version__='$Revision: 1.48 $'[11:-2]
import os, AccessControl, Acquisition, sys, types import os, AccessControl, Acquisition, sys, types
from types import StringType from types import StringType
from Globals import DTMLFile, ImageFile, MessageDialog, package_home from Globals import DTMLFile, ImageFile, MessageDialog, package_home
from zLOG import LOG, ERROR, INFO
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from Shared.DC.Scripts.Script import Script, BindingsUI from Shared.DC.Scripts.Script import Script, BindingsUI
......
...@@ -18,6 +18,8 @@ $Id$ ...@@ -18,6 +18,8 @@ $Id$
import time import time
from datetime import date, datetime from datetime import date, datetime
from datetime import tzinfo, timedelta from datetime import tzinfo, timedelta
import logging
logger = logging.getLogger('UnIndex')
from types import StringType, FloatType, IntType from types import StringType, FloatType, IntType
import BTrees.Length import BTrees.Length
...@@ -28,7 +30,6 @@ from DateTime.DateTime import DateTime ...@@ -28,7 +30,6 @@ from DateTime.DateTime import DateTime
from Globals import DTMLFile from Globals import DTMLFile
from OFS.PropertyManager import PropertyManager from OFS.PropertyManager import PropertyManager
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from zLOG import LOG, ERROR
from zope.interface import implements from zope.interface import implements
from Products.PluginIndexes.common import safe_callable from Products.PluginIndexes.common import safe_callable
...@@ -144,7 +145,7 @@ class DateIndex(UnIndex, PropertyManager): ...@@ -144,7 +145,7 @@ class DateIndex(UnIndex, PropertyManager):
except ConflictError: except ConflictError:
raise raise
except: except:
LOG('UnIndex', ERROR, logger.error(
("Should not happen: ConvertedDate was there," ("Should not happen: ConvertedDate was there,"
" now it's not, for document with id %s" % " now it's not, for document with id %s" %
documentId)) documentId))
......
...@@ -18,10 +18,11 @@ $Id$ ...@@ -18,10 +18,11 @@ $Id$
import operator, warnings import operator, warnings
import re import re
from cgi import escape from cgi import escape
import logging
logger = logging.getLogger('TextIndex')
from types import * from types import *
from Globals import Persistent, DTMLFile from Globals import Persistent, DTMLFile
from zLOG import LOG, ERROR
from Acquisition import Implicit from Acquisition import Implicit
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from BTrees.IOBTree import IOBTree from BTrees.IOBTree import IOBTree
...@@ -376,9 +377,8 @@ class TextIndex(Persistent, Implicit, SimpleItem): ...@@ -376,9 +377,8 @@ class TextIndex(Persistent, Implicit, SimpleItem):
for wid in wids: for wid in wids:
widScores = get(wid, None) widScores = get(wid, None)
if widScores is None: if widScores is None:
LOG('TextIndex', ERROR, logger.error('unindex_object tried to unindex nonexistent'
'unindex_object tried to unindex nonexistent' ' document, wid %s, %s' % (i,wid))
' document, wid %s, %s' % (i,wid))
continue continue
if type(widScores) is TupleType: if type(widScores) is TupleType:
del index[wid] del index[wid]
...@@ -394,9 +394,8 @@ class TextIndex(Persistent, Implicit, SimpleItem): ...@@ -394,9 +394,8 @@ class TextIndex(Persistent, Implicit, SimpleItem):
else: else:
del index[wid] del index[wid]
except (KeyError, IndexError, TypeError): except (KeyError, IndexError, TypeError):
LOG('TextIndex', ERROR, logger.error('unindex_object tried to unindex nonexistent'
'unindex_object tried to unindex nonexistent' ' document %s' % str(i))
' document %s' % str(i))
def __getitem__(self, word): def __getitem__(self, word):
"""Return an InvertedIndex-style result "list" """Return an InvertedIndex-style result "list"
......
...@@ -20,6 +20,7 @@ Python code. ...@@ -20,6 +20,7 @@ Python code.
__version__='$Revision: 1.56 $'[11:-2] __version__='$Revision: 1.56 $'[11:-2]
import sys, os, traceback, re, marshal, new import sys, os, traceback, re, marshal, new
import logging
from Globals import DTMLFile, MessageDialog, package_home from Globals import DTMLFile, MessageDialog, package_home
import AccessControl, OFS, RestrictedPython import AccessControl, OFS, RestrictedPython
from Acquisition import aq_parent from Acquisition import aq_parent
...@@ -33,10 +34,11 @@ from AccessControl import getSecurityManager ...@@ -33,10 +34,11 @@ from AccessControl import getSecurityManager
from OFS.History import Historical, html_diff from OFS.History import Historical, html_diff
from OFS.Cache import Cacheable from OFS.Cache import Cacheable
from AccessControl.ZopeGuards import get_safe_globals, guarded_getattr from AccessControl.ZopeGuards import get_safe_globals, guarded_getattr
from zLOG import LOG, ERROR, INFO, PROBLEM
from zExceptions import Forbidden from zExceptions import Forbidden
import Globals import Globals
LOG = logging.getLogger('Script (Python)')
# Track the Python bytecode version # Track the Python bytecode version
import imp import imp
Python_magic = imp.get_magic() Python_magic = imp.get_magic()
...@@ -209,7 +211,7 @@ class PythonScript(Script, Historical, Cacheable): ...@@ -209,7 +211,7 @@ class PythonScript(Script, Historical, Cacheable):
getattr(self, 'Script_magic', None) != Script_magic): getattr(self, 'Script_magic', None) != Script_magic):
global _log_complaint global _log_complaint
if _log_complaint: if _log_complaint:
LOG(self.meta_type, INFO, _log_complaint) LOG.info(_log_complaint)
_log_complaint = 0 _log_complaint = 0
# Changes here won't get saved, unless this Script is edited. # Changes here won't get saved, unless this Script is edited.
body = self._body.rstrip() body = self._body.rstrip()
...@@ -438,7 +440,7 @@ class PythonScript(Script, Historical, Cacheable): ...@@ -438,7 +440,7 @@ class PythonScript(Script, Historical, Cacheable):
else: else:
self._makeFunction() self._makeFunction()
except: except:
LOG(self.meta_type, ERROR, 'write failed', error=sys.exc_info()) LOG.error('write failed', error=sys.exc_info())
raise raise
def manage_FTPget(self): def manage_FTPget(self):
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
############################################################################ ############################################################################
import re, time, sys import re, time, sys
import logging
logger = logging.getLogger('Session Tracking')
import Globals import Globals
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Acquisition import Implicit, Explicit, aq_base from Acquisition import Implicit, Explicit, aq_base
...@@ -19,7 +22,7 @@ from Persistence import Persistent ...@@ -19,7 +22,7 @@ from Persistence import Persistent
from AccessControl.Owned import Owned from AccessControl.Owned import Owned
from AccessControl.Role import RoleManager from AccessControl.Role import RoleManager
from App.Management import Tabs from App.Management import Tabs
from zLOG import LOG, WARNING, BLATHER from zLOG.EventLogger import CUSTOM_BLATHER
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
import SessionInterfaces import SessionInterfaces
from SessionPermissions import * from SessionPermissions import *
...@@ -205,7 +208,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -205,7 +208,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
transactions for mounted storages. """ transactions for mounted storages. """
if self.obpath is None: if self.obpath is None:
err = 'Session data container is unspecified in %s' % self.getId() err = 'Session data container is unspecified in %s' % self.getId()
LOG('Session Tracking', WARNING, err) logger.warn(err)
raise SessionIdManagerErr, err raise SessionIdManagerErr, err
try: try:
# This should arguably use restrictedTraverse, but it # This should arguably use restrictedTraverse, but it
...@@ -215,7 +218,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs): ...@@ -215,7 +218,7 @@ class SessionDataManager(Item, Implicit, Persistent, RoleManager, Owned, Tabs):
# hasattr hides conflicts # hasattr hides conflicts
if DEBUG and not getattr(self, '_v_wrote_dc_type', None): if DEBUG and not getattr(self, '_v_wrote_dc_type', None):
args = '/'.join(self.obpath) args = '/'.join(self.obpath)
LOG('Session Tracking', BLATHER, logger.log(CUSTOM_BLATHER,
'External data container at %s in use' % args) 'External data container at %s in use' % args)
self._v_wrote_dc_type = 1 self._v_wrote_dc_type = 1
return self.unrestrictedTraverse(self.obpath) return self.unrestrictedTraverse(self.obpath)
...@@ -281,7 +284,7 @@ class SessionDataManagerTraverser(Persistent): ...@@ -281,7 +284,7 @@ class SessionDataManagerTraverser(Persistent):
getSessionData = sdm.getSessionData getSessionData = sdm.getSessionData
except: except:
msg = 'Session automatic traversal failed to get session data' msg = 'Session automatic traversal failed to get session data'
LOG('Session Tracking', WARNING, msg, error=sys.exc_info()) logger.warn(msg, error=sys.exc_info())
return return
# set the getSessionData method in the "lazy" namespace # set the getSessionData method in the "lazy" namespace
......
...@@ -41,7 +41,7 @@ from OFS.Application import Application ...@@ -41,7 +41,7 @@ from OFS.Application import Application
from OFS.Folder import Folder from OFS.Folder import Folder
import sys import sys
import traceback import traceback
from zLOG import log_time from zLOG.EventLogger import log_time
sys.setcheckinterval(200) sys.setcheckinterval(200)
from Products.Transience.tests import fauxtime from Products.Transience.tests import fauxtime
......
...@@ -22,6 +22,7 @@ import random ...@@ -22,6 +22,7 @@ import random
import sys import sys
import os import os
import thread import thread
import logging
from cgi import escape from cgi import escape
import Globals import Globals
...@@ -40,7 +41,7 @@ from AccessControl import ClassSecurityInfo, getSecurityManager ...@@ -40,7 +41,7 @@ from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager, \ from AccessControl.SecurityManagement import newSecurityManager, \
setSecurityManager setSecurityManager
from AccessControl.User import nobody from AccessControl.User import nobody
from zLOG import LOG, WARNING, INFO
from TransientObject import TransientObject from TransientObject import TransientObject
from Fake import FakeIOBTree from Fake import FakeIOBTree
...@@ -60,6 +61,8 @@ DEBUG = int(os.environ.get('Z_TOC_DEBUG', 0)) ...@@ -60,6 +61,8 @@ DEBUG = int(os.environ.get('Z_TOC_DEBUG', 0))
_marker = [] _marker = []
LOG = logging.getLogger('Transience')
def setStrict(on=''): def setStrict(on=''):
""" Turn on assertions (which may cause conflicts) """ """ Turn on assertions (which may cause conflicts) """
global STRICT global STRICT
...@@ -72,7 +75,7 @@ def TLOG(*args): ...@@ -72,7 +75,7 @@ def TLOG(*args):
for arg in args: for arg in args:
sargs.append(str(arg)) sargs.append(str(arg))
msg = ' '.join(sargs) msg = ' '.join(sargs)
LOG('Transience', INFO, msg) LOG.info(msg)
constructTransientObjectContainerForm = HTMLFile( constructTransientObjectContainerForm = HTMLFile(
'dtml/addTransientObjectContainer', globals()) 'dtml/addTransientObjectContainer', globals())
...@@ -434,7 +437,7 @@ class TransientObjectContainer(SimpleItem): ...@@ -434,7 +437,7 @@ class TransientObjectContainer(SimpleItem):
length = self._length() # XXX ReadConflictError hotspot length = self._length() # XXX ReadConflictError hotspot
if self._limit and length >= self._limit: if self._limit and length >= self._limit:
LOG('Transience', WARNING, LOG.warning(
('Transient object container %s max subobjects ' ('Transient object container %s max subobjects '
'reached' % self.getId()) 'reached' % self.getId())
) )
...@@ -796,8 +799,7 @@ class TransientObjectContainer(SimpleItem): ...@@ -796,8 +799,7 @@ class TransientObjectContainer(SimpleItem):
except (KeyError, AttributeError): except (KeyError, AttributeError):
path = self.getPhysicalPath() path = self.getPhysicalPath()
err = 'No such onAdd/onDelete method %s referenced via %s' err = 'No such onAdd/onDelete method %s referenced via %s'
LOG('Transience', LOG.warning(
WARNING,
err % (callback, '/'.join(path)), err % (callback, '/'.join(path)),
error=sys.exc_info() error=sys.exc_info()
) )
...@@ -817,8 +819,7 @@ class TransientObjectContainer(SimpleItem): ...@@ -817,8 +819,7 @@ class TransientObjectContainer(SimpleItem):
except: except:
# dont raise, just log # dont raise, just log
path = self.getPhysicalPath() path = self.getPhysicalPath()
LOG('Transience', LOG.warning(
WARNING,
'%s failed when calling %s in %s' % (name,callback, '%s failed when calling %s in %s' % (name,callback,
'/'.join(path)), '/'.join(path)),
error=sys.exc_info() error=sys.exc_info()
...@@ -828,8 +829,7 @@ class TransientObjectContainer(SimpleItem): ...@@ -828,8 +829,7 @@ class TransientObjectContainer(SimpleItem):
else: else:
err = '%s in %s attempted to call non-callable %s' err = '%s in %s attempted to call non-callable %s'
path = self.getPhysicalPath() path = self.getPhysicalPath()
LOG('Transience', LOG.warning(
WARNING,
err % (name, '/'.join(path), callback), err % (name, '/'.join(path), callback),
error=sys.exc_info() error=sys.exc_info()
) )
......
...@@ -15,7 +15,7 @@ $Id$ ...@@ -15,7 +15,7 @@ $Id$
""" """
import time, sys import time, sys
from zLOG import LOG, INFO import logging
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
...@@ -92,7 +92,8 @@ class ZLogHandler(StdoutHandler): ...@@ -92,7 +92,8 @@ class ZLogHandler(StdoutHandler):
__implements__ = IProgressHandler __implements__ = IProgressHandler
def output(self, text): def output(self, text):
LOG(self._ident, INFO, text) logger = logging.getLogger(self._ident)
logger.info(text)
class FilelogHandler(StdoutHandler): class FilelogHandler(StdoutHandler):
......
...@@ -37,7 +37,6 @@ from Products.PluginIndexes.common.PluggableIndex \ ...@@ -37,7 +37,6 @@ from Products.PluginIndexes.common.PluggableIndex \
import PluggableIndexInterface import PluggableIndexInterface
from Products.PluginIndexes.interfaces import IPluggableIndex from Products.PluginIndexes.interfaces import IPluggableIndex
from Products.PluginIndexes.TextIndex import Splitter from Products.PluginIndexes.TextIndex import Splitter
from zLOG import LOG
from zope.interface import implements from zope.interface import implements
from Catalog import Catalog, CatalogError from Catalog import Catalog, CatalogError
...@@ -47,7 +46,10 @@ from ProgressHandler import ZLogHandler ...@@ -47,7 +46,10 @@ from ProgressHandler import ZLogHandler
from ZCatalogIndexes import ZCatalogIndexes from ZCatalogIndexes import ZCatalogIndexes
LOG = logging.getLogger('Zope.ZCatalog') logger = logging.getLogger('Zope.ZCatalog')
# BBB: some products apparently import 'LOG' from here! Gone in 2.10.
from zLOG import LOG
manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals()) manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals())
...@@ -304,8 +306,8 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -304,8 +306,8 @@ class ZCatalog(Folder, Persistent, Implicit):
except ConflictError: except ConflictError:
raise raise
except: except:
LOG.error('Recataloging object at %s failed' % p, logger.error('Recataloging object at %s failed' % p,
exc_info=sys.exc_info()) exc_info=sys.exc_info())
if pghandler: pghandler.finish() if pghandler: pghandler.finish()
...@@ -494,8 +496,8 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -494,8 +496,8 @@ class ZCatalog(Folder, Persistent, Implicit):
if obj is None: if obj is None:
obj = self.resolve_url(p, REQUEST) obj = self.resolve_url(p, REQUEST)
if obj is None: if obj is None:
LOG.error('reindexIndex could not resolve ' logger.error('reindexIndex could not resolve '
'an object from the uid %r.' % p) 'an object from the uid %r.' % p)
else: else:
# don't update metadata when only reindexing a single # don't update metadata when only reindexing a single
# index via the UI # index via the UI
...@@ -924,7 +926,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -924,7 +926,7 @@ class ZCatalog(Folder, Persistent, Implicit):
classes. classes.
""" """
LOG.info('Start migration of indexes for %s' % self.absolute_url(1)) logger.info('Start migration of indexes for %s' % self.absolute_url(1))
for idx in self.Indexes.objectValues(): for idx in self.Indexes.objectValues():
bases = [str(name) for name in idx.__class__.__bases__] bases = [str(name) for name in idx.__class__.__bases__]
...@@ -941,7 +943,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -941,7 +943,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if found: if found:
idx_type = idx.meta_type idx_type = idx.meta_type
idx_id = idx.getId() idx_id = idx.getId()
LOG.info('processing index %s' % idx_id) logger.info('processing index %s' % idx_id)
indexed_attrs = getattr(idx, 'indexed_attrs', None) indexed_attrs = getattr(idx, 'indexed_attrs', None)
...@@ -963,7 +965,8 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -963,7 +965,8 @@ class ZCatalog(Folder, Persistent, Implicit):
self.manage_reindexIndex(idx_id, REQUEST) self.manage_reindexIndex(idx_id, REQUEST)
self._migrated_280 = True self._migrated_280 = True
LOG.info('Finished migration of indexes for %s' % self.absolute_url(1)) logger.info('Finished migration of indexes for %s'
% self.absolute_url(1))
if RESPONSE: if RESPONSE:
RESPONSE.redirect( URL1 + RESPONSE.redirect( URL1 +
......
...@@ -15,6 +15,9 @@ __doc__='''Generic Database Connection Support ...@@ -15,6 +15,9 @@ __doc__='''Generic Database Connection Support
$Id$''' $Id$'''
__version__='$Revision: 1.39 $'[11:-2] __version__='$Revision: 1.39 $'[11:-2]
import logging
logger = logging.getLogger('Shared.DC.ZRDB.Connection')
import Globals, OFS.SimpleItem, AccessControl.Role, Acquisition, sys import Globals, OFS.SimpleItem, AccessControl.Role, Acquisition, sys
from DateTime import DateTime from DateTime import DateTime
from App.Dialogs import MessageDialog from App.Dialogs import MessageDialog
...@@ -24,7 +27,6 @@ from Aqueduct import custom_default_report ...@@ -24,7 +27,6 @@ from Aqueduct import custom_default_report
from cStringIO import StringIO from cStringIO import StringIO
from Results import Results from Results import Results
from sys import exc_info from sys import exc_info
from zLOG import LOG, ERROR
from cgi import escape from cgi import escape
import DocumentTemplate, RDB import DocumentTemplate, RDB
from zExceptions import BadRequest from zExceptions import BadRequest
...@@ -68,10 +70,8 @@ class Connection( ...@@ -68,10 +70,8 @@ class Connection(
if self.connection_string: if self.connection_string:
try: self.connect(self.connection_string) try: self.connect(self.connection_string)
except: except:
LOG('Shared.DC.ZRDB.Connection', logger.error('Error connecting to relational database.',
ERROR, error=exc_info())
'Error connecting to relational database.',
error=exc_info())
def title_and_id(self): def title_and_id(self):
s=Connection.inheritedAttribute('title_and_id')(self) s=Connection.inheritedAttribute('title_and_id')(self)
...@@ -150,10 +150,8 @@ class Connection( ...@@ -150,10 +150,8 @@ class Connection(
if hasattr(self,'_v_database_connection'): if hasattr(self,'_v_database_connection'):
self._v_database_connection.close() self._v_database_connection.close()
except: except:
LOG('Shared.DC.ZRDB.Connection', logger.error('Error closing relational database connection.',
ERROR, error=exc_info())
'Error closing relational database connection.',
error=exc_info())
self._v_connected='' self._v_connected=''
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST) return self.manage_main(self, REQUEST)
......
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.2 $'[11:-2]
import sys, os import sys, os
import signal, zLOG import signal
import logging
LOG = logging.getLogger('Signals')
class SignalHandler: class SignalHandler:
...@@ -36,9 +39,8 @@ class SignalHandler: ...@@ -36,9 +39,8 @@ class SignalHandler:
items = self.registry[signum] = [] items = self.registry[signum] = []
signal.signal(signum, self.signalHandler) signal.signal(signum, self.signalHandler)
signame = get_signal_name(signum) signame = get_signal_name(signum)
zLOG.LOG('Z2', zLOG.BLATHER, "Installed sighandler for %s" % ( LOG.debug("Installed sighandler for %s" % signame)
signame
))
items.insert(0, handler) items.insert(0, handler)
def getRegisteredSignals(self): def getRegisteredSignals(self):
...@@ -49,7 +51,7 @@ class SignalHandler: ...@@ -49,7 +51,7 @@ class SignalHandler:
def signalHandler(self, signum, frame): def signalHandler(self, signum, frame):
"""Meta signal handler that dispatches to registered handlers.""" """Meta signal handler that dispatches to registered handlers."""
signame = get_signal_name(signum) signame = get_signal_name(signum)
zLOG.LOG('Z2', zLOG.INFO , "Caught signal %s" % signame) LOG.info("Caught signal %s" % signame)
for handler in self.registry.get(signum, []): for handler in self.registry.get(signum, []):
# Never let a bad handler prevent the standard signal # Never let a bad handler prevent the standard signal
...@@ -59,9 +61,7 @@ class SignalHandler: ...@@ -59,9 +61,7 @@ class SignalHandler:
# if we trap SystemExit, we can't restart # if we trap SystemExit, we can't restart
raise raise
except: except:
zLOG.LOG('Z2', zLOG.WARNING, LOG.warn('A handler for %s failed!' % signame, exc_info=sys.exc_info())
'A handler for %s failed!' % signame,
error=sys.exc_info())
_signals = None _signals = None
......
...@@ -16,9 +16,8 @@ Generic expat-based XML parser base class. ...@@ -16,9 +16,8 @@ Generic expat-based XML parser base class.
""" """
import xml.parsers.expat import xml.parsers.expat
import logging
import zLOG logger = logging.getLogger('TAL.XMLParser')
XMLParseError = xml.parsers.expat.ExpatError XMLParseError = xml.parsers.expat.ExpatError
...@@ -56,8 +55,7 @@ class XMLParser: ...@@ -56,8 +55,7 @@ class XMLParser:
try: try:
self.parser.ordered_attributes = self.ordered_attributes self.parser.ordered_attributes = self.ordered_attributes
except AttributeError: except AttributeError:
zLOG.LOG("TAL.XMLParser", zLOG.INFO, logger.info("Can't set ordered_attributes")
"Can't set ordered_attributes")
self.ordered_attributes = 0 self.ordered_attributes = 0
for name in self.handler_names: for name in self.handler_names:
method = getattr(self, name, None) method = getattr(self, name, None)
...@@ -65,8 +63,7 @@ class XMLParser: ...@@ -65,8 +63,7 @@ class XMLParser:
try: try:
setattr(p, name, method) setattr(p, name, method)
except AttributeError: except AttributeError:
zLOG.LOG("TAL.XMLParser", zLOG.PROBLEM, logger.warn("Can't set expat handler %s" % name)
"Can't set expat handler %s" % name)
def createParser(self, encoding=None): def createParser(self, encoding=None):
return xml.parsers.expat.ParserCreate(encoding, ' ') return xml.parsers.expat.ParserCreate(encoding, ' ')
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
__version__='$Revision: 1.12 $'[11:-2] __version__='$Revision: 1.12 $'[11:-2]
"""BeforeTraverse interface and helper classes""" """BeforeTraverse interface and helper classes"""
import logging
from Acquisition import aq_base from Acquisition import aq_base
from zLOG import LOG, ERROR
import sys import sys
# Interface # Interface
...@@ -86,6 +86,7 @@ class MultiHook: ...@@ -86,6 +86,7 @@ class MultiHook:
MultiHook calls the named hook from the class of the container, then MultiHook calls the named hook from the class of the container, then
the prior hook, then all the hooks in its list. the prior hook, then all the hooks in its list.
""" """
logger = logging.getLogger('MultiHook')
def __init__(self, hookname, prior, defined_in_class): def __init__(self, hookname, prior, defined_in_class):
self._hookname = hookname self._hookname = hookname
self._prior = prior self._prior = prior
...@@ -103,7 +104,7 @@ class MultiHook: ...@@ -103,7 +104,7 @@ class MultiHook:
try: try:
cob(container, request) cob(container, request)
except TypeError: except TypeError:
LOG('MultiHook', ERROR, '%s call %s failed.' % ( self.logger.error('%s call %s failed.' % (
`self._hookname`, `cob`), error=sys.exc_info()) `self._hookname`, `cob`), error=sys.exc_info())
def add(self, cob): def add(self, cob):
...@@ -120,6 +121,7 @@ class NameCaller: ...@@ -120,6 +121,7 @@ class NameCaller:
>>> registerBeforeTraverse(folder, NameCaller('preop'), 'XApp') >>> registerBeforeTraverse(folder, NameCaller('preop'), 'XApp')
""" """
logger = logging.getLogger('BeforeTraverse')
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -149,8 +151,6 @@ class NameCaller: ...@@ -149,8 +151,6 @@ class NameCaller:
# Only catch exceptions that are likely to be logic errors. # Only catch exceptions that are likely to be logic errors.
# We shouldn't catch Redirects, Unauthorizeds, etc. since # We shouldn't catch Redirects, Unauthorizeds, etc. since
# the programmer may want to raise them deliberately. # the programmer may want to raise them deliberately.
from zLOG import LOG, ERROR
import sys import sys
LOG('BeforeTraverse', ERROR, self.logger.error('Error while invoking hook: "%s"'
'Error while invoking hook: "%s"' % self.name, error= % self.name, error=sys.exc_info())
sys.exc_info())
...@@ -170,8 +170,9 @@ class MonitorServerFactory(ServerFactory): ...@@ -170,8 +170,9 @@ class MonitorServerFactory(ServerFactory):
if password is None: if password is None:
msg = ('Monitor server not started because no emergency user ' msg = ('Monitor server not started because no emergency user '
'exists.') 'exists.')
import zLOG import logging
zLOG.LOG("Zope", zLOG.ERROR, msg) logger = logging.getLogger('Zope')
logger.error(msg)
return return
from ZServer.medusa.monitor import secure_monitor_server from ZServer.medusa.monitor import secure_monitor_server
return secure_monitor_server(hostname=self.host, port=self.port, return secure_monitor_server(hostname=self.host, port=self.port,
......
...@@ -258,14 +258,20 @@ class ZopeCmd(ZDCmd): ...@@ -258,14 +258,20 @@ class ZopeCmd(ZDCmd):
pid = os.fork() pid = os.fork()
if pid == 0: # child if pid == 0: # child
os.execv(self.options.python, args) os.execv(self.options.python, args)
else:
os.waitpid(pid, 0) # Parent process running (execv replaces process in child
while True:
try:
os.waitpid(pid, 0)
except (OSError, KeyboardInterrupt):
continue
else:
break
def help_test(self): def help_test(self):
print "test [args]+ -- run unit / functional tests." print "test [args]+ -- run unit / functional tests."
print " See $ZOPE_HOME/bin/test.py --help for syntax." print " See $ZOPE_HOME/bin/test.py --help for syntax."
def main(args=None): def main(args=None):
# This is exactly like zdctl.main(), but uses ZopeCtlOptions and # This is exactly like zdctl.main(), but uses ZopeCtlOptions and
# ZopeCmd instead of ZDCtlOptions and ZDCmd, so the default values # ZopeCmd instead of ZDCtlOptions and ZDCmd, so the default values
......
...@@ -21,8 +21,10 @@ $Id$ ...@@ -21,8 +21,10 @@ $Id$
""" """
__version__ ='$Revision: 1.1.2.2 $'[11:-2] __version__ ='$Revision: 1.1.2.2 $'[11:-2]
import logging
logger = logging.getLogger('TemporaryStorage')
from zLOG import LOG, BLATHER from zLOG.EventLogger import CUSTOM_BLATHER
from ZODB.serialize import referencesf from ZODB.serialize import referencesf
from ZODB import POSException from ZODB import POSException
from ZODB.BaseStorage import BaseStorage from ZODB.BaseStorage import BaseStorage
...@@ -182,7 +184,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage): ...@@ -182,7 +184,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
if version: if version:
# we allow a version to be in use although we don't # we allow a version to be in use although we don't
# support versions in the storage. # support versions in the storage.
LOG('TemporaryStorage', BLATHER, logging.log(CUSTOM_BLATHER,
('versions in use with TemporaryStorage although Temporary' ('versions in use with TemporaryStorage although Temporary'
'Storage doesnt support versions'), 'Storage doesnt support versions'),
) )
......
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