[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TopicIndex - FilteredSet.py:1.1.2.6

Andreas Jung andreas@zope.com
Tue, 16 Oct 2001 12:55:00 -0400


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TopicIndex
In directory cvs.zope.org:/tmp/cvs-serv12641

Modified Files:
      Tag: ajung-topicindex
	FilteredSet.py 
Log Message:
added AttributeFilteredSet


=== Zope/lib/python/Products/PluginIndexes/TopicIndex/FilteredSet.py 1.1.2.5 => 1.1.2.6 ===
 
 
+class AttributeFilteredSet(FilteredSetBase):
+
+    meta_type = 'AttributeFilteredSet'
+
+    def index_object(self, documentId, o):
+
+        if hasattr(o,self.id):
+            attr = getattr(o,self.id)
+            if callable(attr):
+                attr = attr()
+
+        try:
+            if attr in self.expr:
+                self.ids.insert(documentId)
+        except: 
+            print 'sux'
+    
+
+
+
 class PythonFilteredSet(FilteredSetBase):
 
     meta_type = 'PythonFilteredSet'
@@ -148,6 +168,9 @@
 
     if f_type=='PythonFilteredSet':
         return PythonFilteredSet(f_id, expr)
+
+    elif f_type=='AttributeFilteredSet':
+        return CatalogFilteredSet(f_id, expr)
 
     elif f_type=='CatalogFilteredSet':
         return CatalogFilteredSet(f_id, expr)