Commit cfe41292 authored by Tino Wildenhain's avatar Tino Wildenhain

UnIndex.py now accepts any mapping type for

the extra argument. Its parameter 'indexed_attrs'
can be string with comma delimited attribute names
or list/tuple

This fixes: # 1688
parent 8c9fb0ee
......@@ -16,7 +16,7 @@ $Id$"""
import sys
from cgi import escape
from logging import getLogger
from types import IntType
from types import IntType, StringTypes
from BTrees.OOBTree import OOBTree, OOSet
from BTrees.IOBTree import IOBTree
......@@ -65,8 +65,10 @@ class UnIndex(SimpleItem):
You will also need to pass in an object in the index and
uninded methods for this to work.
'extra' -- a record-style object that keeps additional
index-related parameters
'extra' -- a mapping object that keeps additional
index-related parameters - subitem 'indexed_attrs'
can be string with comma separated attribute names or
a list
'caller' -- reference to the calling object (usually
a (Z)Catalog instance
......@@ -80,10 +82,12 @@ class UnIndex(SimpleItem):
# allow index to index multiple attributes
try:
self.indexed_attrs = extra.indexed_attrs.split(',')
self.indexed_attrs = [
attr.strip() for attr in self.indexed_attrs if attr ]
if len(self.indexed_attrs) == 0: self.indexed_attrs = [ self.id ]
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 ]
......
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