Commit 04227d95 authored by Andreas Jung's avatar Andreas Jung

- some import cleanup

- fix for collector #1721
parent aa139459
......@@ -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
......
......@@ -19,7 +19,6 @@ from logging import getLogger
from ZODB.POSException import ConflictError
from BTrees.IIBTree import IITreeSet
from Persistence import Persistent
from Globals import DTMLFile
from RestrictedPython.Eval import RestrictionCapableEval
......
......@@ -11,7 +11,7 @@
#
##############################################################################
import os ,sys, re, unittest
import unittest
import ZODB
from Products.PluginIndexes.TopicIndex.TopicIndex import TopicIndex
......
......@@ -16,9 +16,8 @@ $Id$"""
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 @@ class UnIndex(SimpleItem):
'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 @@ class UnIndex(SimpleItem):
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()
......
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