[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/
- some import cleanup
Andreas Jung
andreas at andreas-jung.com
Sat Mar 5 07:45:24 EST 2005
Log message for revision 29401:
- some import cleanup
- fix for collector #1721
Changed:
U Zope/trunk/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
U Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py
U Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py
U Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py
-=-
Modified: Zope/trunk/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
===================================================================
--- Zope/trunk/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py 2005-03-05 12:38:07 UTC (rev 29400)
+++ Zope/trunk/lib/python/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py 2005-03-05 12:45:24 UTC (rev 29401)
@@ -15,13 +15,11 @@
"""
import os
-import sys
from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.UnIndex import UnIndex
from Products.PluginIndexes.common.util import parseIndexRequest
from Products.PluginIndexes.common import safe_callable
-from OFS.SimpleItem import SimpleItem
from BTrees.IOBTree import IOBTree
from BTrees.IIBTree import IISet, IITreeSet, union, intersection, multiunion
Modified: Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py
===================================================================
--- Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py 2005-03-05 12:38:07 UTC (rev 29400)
+++ Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py 2005-03-05 12:45:24 UTC (rev 29401)
@@ -19,7 +19,6 @@
from ZODB.POSException import ConflictError
from BTrees.IIBTree import IITreeSet
from Persistence import Persistent
-from Globals import DTMLFile
from RestrictedPython.Eval import RestrictionCapableEval
Modified: Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py
===================================================================
--- Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py 2005-03-05 12:38:07 UTC (rev 29400)
+++ Zope/trunk/lib/python/Products/PluginIndexes/TopicIndex/tests/testTopicIndex.py 2005-03-05 12:45:24 UTC (rev 29401)
@@ -11,7 +11,7 @@
#
##############################################################################
-import os ,sys, re, unittest
+import unittest
import ZODB
from Products.PluginIndexes.TopicIndex.TopicIndex import TopicIndex
Modified: Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py
===================================================================
--- Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py 2005-03-05 12:38:07 UTC (rev 29400)
+++ Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py 2005-03-05 12:45:24 UTC (rev 29401)
@@ -16,9 +16,8 @@
import sys
from cgi import escape
from logging import getLogger
-from types import IntType, StringTypes
-from BTrees.OOBTree import OOBTree, OOSet
+from BTrees.OOBTree import OOBTree
from BTrees.IOBTree import IOBTree
from BTrees.IIBTree import IITreeSet, IISet, union, intersection
from OFS.SimpleItem import SimpleItem
@@ -73,6 +72,14 @@
'caller' -- reference to the calling object (usually
a (Z)Catalog instance
"""
+
+ def _get(o, k, default):
+ """ return a value for a given key of a dict/record 'o' """
+ if isinstance(o, dict):
+ return o.get(k, default)
+ else:
+ return getattr(o, k, default)
+
self.id = id
self.ignore_ex=ignore_ex # currently unimplimented
self.call_methods=call_methods
@@ -81,15 +88,12 @@
self.useOperator = 'or'
# allow index to index multiple attributes
- try:
- ia=extra['indexed_attrs']
- if type(ia) in StringTypes:
- self.indexed_attrs = ia.split(',')
- else:
- self.indexed_attrs = list(ia)
- self.indexed_attrs = [ attr.strip() for attr in self.indexed_attrs if attr ] or [self.id]
- except:
- self.indexed_attrs = [ self.id ]
+ ia = _get(extra, 'indexed_attrs', id)
+ if isinstance(ia, str):
+ self.indexed_attrs = ia.split(',')
+ else:
+ self.indexed_attrs = list(ia)
+ self.indexed_attrs = [ attr.strip() for attr in self.indexed_attrs if attr ]
self._length = BTrees.Length.Length()
self.clear()
More information about the Zope-Checkins
mailing list