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

- some import cleanup

- fix for collector #1721
parent aa139459
...@@ -15,13 +15,11 @@ ...@@ -15,13 +15,11 @@
""" """
import os import os
import sys
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.UnIndex import UnIndex from Products.PluginIndexes.common.UnIndex import UnIndex
from Products.PluginIndexes.common.util import parseIndexRequest from Products.PluginIndexes.common.util import parseIndexRequest
from Products.PluginIndexes.common import safe_callable from Products.PluginIndexes.common import safe_callable
from OFS.SimpleItem import SimpleItem
from BTrees.IOBTree import IOBTree from BTrees.IOBTree import IOBTree
from BTrees.IIBTree import IISet, IITreeSet, union, intersection, multiunion from BTrees.IIBTree import IISet, IITreeSet, union, intersection, multiunion
......
...@@ -19,7 +19,6 @@ from logging import getLogger ...@@ -19,7 +19,6 @@ from logging import getLogger
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from BTrees.IIBTree import IITreeSet from BTrees.IIBTree import IITreeSet
from Persistence import Persistent from Persistence import Persistent
from Globals import DTMLFile
from RestrictedPython.Eval import RestrictionCapableEval from RestrictedPython.Eval import RestrictionCapableEval
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
import os ,sys, re, unittest import unittest
import ZODB import ZODB
from Products.PluginIndexes.TopicIndex.TopicIndex import TopicIndex from Products.PluginIndexes.TopicIndex.TopicIndex import TopicIndex
......
...@@ -16,9 +16,8 @@ $Id$""" ...@@ -16,9 +16,8 @@ $Id$"""
import sys import sys
from cgi import escape from cgi import escape
from logging import getLogger 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.IOBTree import IOBTree
from BTrees.IIBTree import IITreeSet, IISet, union, intersection from BTrees.IIBTree import IITreeSet, IISet, union, intersection
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
...@@ -73,6 +72,14 @@ class UnIndex(SimpleItem): ...@@ -73,6 +72,14 @@ class UnIndex(SimpleItem):
'caller' -- reference to the calling object (usually 'caller' -- reference to the calling object (usually
a (Z)Catalog instance 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.id = id
self.ignore_ex=ignore_ex # currently unimplimented self.ignore_ex=ignore_ex # currently unimplimented
self.call_methods=call_methods self.call_methods=call_methods
...@@ -81,15 +88,12 @@ class UnIndex(SimpleItem): ...@@ -81,15 +88,12 @@ class UnIndex(SimpleItem):
self.useOperator = 'or' self.useOperator = 'or'
# allow index to index multiple attributes # allow index to index multiple attributes
try: ia = _get(extra, 'indexed_attrs', id)
ia=extra['indexed_attrs'] if isinstance(ia, str):
if type(ia) in StringTypes: self.indexed_attrs = ia.split(',')
self.indexed_attrs = ia.split(',') else:
else: self.indexed_attrs = list(ia)
self.indexed_attrs = list(ia) self.indexed_attrs = [ attr.strip() for attr in self.indexed_attrs if attr ]
self.indexed_attrs = [ attr.strip() for attr in self.indexed_attrs if attr ] or [self.id]
except:
self.indexed_attrs = [ self.id ]
self._length = BTrees.Length.Length() self._length = BTrees.Length.Length()
self.clear() 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