[Zope-Checkins]
SVN: Zope/branches/ajung-indexes-desuxing-branch/lib/python/Products/PluginIndexes/common/UnIndex.py
'extra' can now be a mapping
Andreas Jung
andreas at andreas-jung.com
Tue Feb 1 09:40:28 EST 2005
Log message for revision 29006:
'extra' can now be a mapping
Changed:
U Zope/branches/ajung-indexes-desuxing-branch/lib/python/Products/PluginIndexes/common/UnIndex.py
-=-
Modified: Zope/branches/ajung-indexes-desuxing-branch/lib/python/Products/PluginIndexes/common/UnIndex.py
===================================================================
--- Zope/branches/ajung-indexes-desuxing-branch/lib/python/Products/PluginIndexes/common/UnIndex.py 2005-01-31 20:53:55 UTC (rev 29005)
+++ Zope/branches/ajung-indexes-desuxing-branch/lib/python/Products/PluginIndexes/common/UnIndex.py 2005-02-01 14:40:27 UTC (rev 29006)
@@ -65,12 +65,21 @@
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 record-style object or a dictionary that keeps
+ additional index-related parameters
'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
@@ -80,10 +89,11 @@
# allow index to index multiple attributes
try:
- self.indexed_attrs = extra.indexed_attrs.split(',')
+ self.indexed_attrs = _get(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 ]
+ if not self.indexed_attrs:
+ self.indexed_attrs = [ self.id ]
except:
self.indexed_attrs = [ self.id ]
More information about the Zope-Checkins
mailing list