[Zope-Checkins] CVS: Products/PluginIndexes/common -
UnIndex.py:1.20.2.4
Andreas Jung
andreas at andreas-jung.com
Sat Mar 5 07:29:24 EST 2005
Update of /cvs-repository/Products/PluginIndexes/common
In directory cvs.zope.org:/tmp/cvs-serv20510/lib/python/Products/PluginIndexes/common
Modified Files:
Tag: Zope-2_7-branch
UnIndex.py
Log Message:
- some import cleanup
- fix for collector #1721
=== Products/PluginIndexes/common/UnIndex.py 1.20.2.3 => 1.20.2.4 ===
--- Products/PluginIndexes/common/UnIndex.py:1.20.2.3 Tue Feb 1 11:20:05 2005
+++ Products/PluginIndexes/common/UnIndex.py Sat Mar 5 07:29:23 2005
@@ -17,7 +17,7 @@
import sys
from cgi import escape
-from types import StringType, StringTypes, ListType, IntType, TupleType
+from types import IntType
from Globals import Persistent
from Acquisition import Implicit
@@ -32,8 +32,6 @@
from Products.PluginIndexes.common.util import parseIndexRequest
from Products.PluginIndexes.common import safe_callable
-from types import StringTypes
-
_marker = []
class UnIndex(Persistent, Implicit, SimpleItem):
@@ -81,6 +79,13 @@
"""
+ 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
@@ -89,18 +94,14 @@
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.__len__=BTrees.Length.Length() # see __len__ method docstring
+ self.__len__ = BTrees.Length.Length() # see __len__ method docstring
self.clear()
def getId(self): return self.id
More information about the Zope-Checkins
mailing list