Commit 8a854815 authored by Andreas Jung's avatar Andreas Jung

zLOG -> logging

parent 9d2ed629
......@@ -12,8 +12,7 @@
##############################################################################
from types import StringType, UnicodeType
from zLOG import LOG, ERROR
from logging import getLogger
from BTrees.OOBTree import OOSet, difference
from Globals import DTMLFile
......@@ -22,6 +21,8 @@ from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.UnIndex import UnIndex
from Products.PluginIndexes.common import safe_callable
LOG = getLogger('Zope.KeywordIndex')
class KeywordIndex(UnIndex):
__implements__ = (PluggableIndex.UniqueValueIndex,
......@@ -121,8 +122,8 @@ class KeywordIndex(UnIndex):
try:
del self._unindex[documentId]
except KeyError:
LOG('UnKeywordIndex', ERROR, 'Attempt to unindex nonexistent'
' document id %s' % documentId)
LOG.error('Attempt to unindex nonexistent'
' document id %s' % documentId)
index_html = DTMLFile('dtml/index', globals())
......
......@@ -11,9 +11,10 @@
#
##############################################################################
__version__ = '$Id: PathIndex.py,v 1.40 2004/01/24 15:48:38 andreasjung Exp $'
__version__ = '$Id: PathIndex.py,v 1.41 2004/04/20 14:30:44 andreasjung Exp $'
from types import StringType, ListType, TupleType
from logging import getLogger
from Globals import Persistent, DTMLFile
from OFS.SimpleItem import SimpleItem
......@@ -21,13 +22,13 @@ from BTrees.IOBTree import IOBTree
from BTrees.OOBTree import OOBTree
from BTrees.IIBTree import IITreeSet, IISet, intersection, union
from BTrees.Length import Length
from zLOG import LOG, ERROR
from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest
from Products.PluginIndexes.common import safe_callable
_marker = []
LOG = getLogger('Zope.PathIndex')
class PathIndex(Persistent, SimpleItem):
""" A path index stores all path components of the physical
......@@ -124,9 +125,8 @@ class PathIndex(Persistent, SimpleItem):
""" hook for (Z)Catalog """
if not self._unindex.has_key(docid):
LOG(self.__class__.__name__, ERROR,
'Attempt to unindex nonexistent document'
' with id %s' % docid)
LOG.error('Attempt to unindex nonexistent document'
' with id %s' % docid)
return
comps = self._unindex[docid].split('/')
......
......@@ -11,16 +11,19 @@
#
##############################################################################
__version__ = '$Id: FilteredSet.py,v 1.7 2004/01/15 23:17:17 tseaver Exp $'
__version__ = '$Id: FilteredSet.py,v 1.8 2004/04/20 14:30:45 andreasjung Exp $'
import sys
from logging import getLogger
from ZODB.POSException import ConflictError
from BTrees.IIBTree import IITreeSet
from Persistence import Persistent
from Globals import DTMLFile
from zLOG import WARNING,LOG
from RestrictedPython.Eval import RestrictionCapableEval
import sys
LOG = getLogger('Zope.TopicIndex.FilteredSet')
class FilteredSetBase(Persistent):
......@@ -29,20 +32,16 @@ class FilteredSetBase(Persistent):
self.expr = expr
self.clear()
def clear(self):
self.ids = IITreeSet()
def index_object(self, documentId, obj):
raise RuntimeError,'index_object not defined'
def unindex_object(self,documentId):
try: self.ids.remove(documentId)
except KeyError: pass
def getId(self):
return self.id
......@@ -63,7 +62,6 @@ class FilteredSetBase(Persistent):
__str__ = __repr__
class PythonFilteredSet(FilteredSetBase):
meta_type = 'PythonFilteredSet'
......@@ -80,10 +78,8 @@ class PythonFilteredSet(FilteredSetBase):
except ConflictError:
raise
except:
LOG('FilteredSet',WARNING,'eval() failed',\
'Object: %s, expr: %s' % (o.getId(),self.expr),\
sys.exc_info())
LOG.warn('eval() failed Object: %s, expr: %s' %\
(o.getId(),self.expr), exc_info=sys.exc_info())
def factory(f_id, f_type, expr):
......
......@@ -11,11 +11,12 @@
#
##############################################################################
__version__ = '$Id: TopicIndex.py,v 1.17 2003/12/31 22:32:21 poster Exp $'
__version__ = '$Id: TopicIndex.py,v 1.18 2004/04/20 14:30:45 andreasjung Exp $'
from logging import getLogger
from Globals import Persistent, DTMLFile
from OFS.SimpleItem import SimpleItem
from zLOG import ERROR, LOG
from BTrees.OOBTree import OOBTree
from BTrees.IIBTree import IITreeSet,intersection,union
......@@ -24,6 +25,7 @@ from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest
_marker = []
LOG = getLogger('Zope.TopicIndex')
class TopicIndex(Persistent, SimpleItem):
......@@ -69,9 +71,8 @@ class TopicIndex(Persistent, SimpleItem):
try:
fs.unindex_object(docid)
except KeyError:
LOG(self.__class__.__name__, ERROR,
'Attempt to unindex document'
' with id %s failed' % docid)
LOG.error('Attempt to unindex document'
' with id %s failed' % docid)
return 1
def numObjects(self):
......
......@@ -13,15 +13,15 @@
"""Simple column indices"""
__version__='$Revision: 1.21 $'[11:-2]
__version__='$Revision: 1.22 $'[11:-2]
import sys
from cgi import escape
from logging import getLogger
from types import StringType, ListType, IntType, TupleType
from Globals import Persistent
from Acquisition import Implicit
from zLOG import LOG, ERROR
from BTrees.OOBTree import OOBTree, OOSet
from BTrees.IOBTree import IOBTree
......@@ -32,8 +32,8 @@ import BTrees.Length
from Products.PluginIndexes.common.util import parseIndexRequest
from Products.PluginIndexes.common import safe_callable
_marker = []
LOG = getLogger('Zope.UnIndex')
class UnIndex(Persistent, Implicit, SimpleItem):
"""UnIndex object interface"""
......@@ -202,17 +202,16 @@ class UnIndex(Persistent, Implicit, SimpleItem):
try: self.__len__.change(-1)
except AttributeError: pass # pre-BTrees-module instance
except:
LOG(self.__class__.__name__, ERROR,
('unindex_object could not remove '
'documentId %s from index %s. This '
'should not happen.'
% (str(documentId), str(self.id))), '',
sys.exc_info())
LOG.error('%s: unindex_object could not remove '
'documentId %s from index %s. This '
'should not happen.' % (self.__class__.__name__,
str(documentId), str(self.id)),
exc_info=sys.exc_info())
else:
LOG(self.__class__.__name__, ERROR,
('unindex_object tried to retrieve set %s '
'from index %s but couldn\'t. This '
'should not happen.' % (repr(entry), str(self.id))))
LOG.error('%s: unindex_object tried to retrieve set %s '
'from index %s but couldn\'t. This '
'should not happen.' % (self.__class__.__name__,
repr(entry), str(self.id)))
def insertForwardIndexEntry(self, entry, documentId):
......@@ -269,9 +268,8 @@ class UnIndex(Persistent, Implicit, SimpleItem):
try:
del self._unindex[documentId]
except:
LOG('UnIndex', ERROR,
'Should not happen: oldDatum was there, now its not,'
'for document with id %s' % documentId)
LOG.error('Should not happen: oldDatum was there, now its not,'
'for document with id %s' % documentId)
if datum is not _marker:
self.insertForwardIndexEntry(datum, documentId)
......@@ -312,8 +310,8 @@ class UnIndex(Persistent, Implicit, SimpleItem):
try:
del self._unindex[documentId]
except:
LOG('UnIndex', ERROR, 'Attempt to unindex nonexistent document'
' with id %s' % documentId)
LOG.error('Attempt to unindex nonexistent document'
' with id %s' % documentId)
def _apply_index(self, request, cid='', type=type):
"""Apply the index to query parameters given in the request arg.
......
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