[Zope-CVS] CVS: Products/PathIndexNG - PathIndexNG.py:1.2

Andreas Jung andreas at andreas-jung.com
Sat Jan 24 12:14:47 EST 2004


Update of /cvs-repository/Products/PathIndexNG
In directory cvs.zope.org:/tmp/cvs-serv8661

Modified Files:
	PathIndexNG.py 
Log Message:
- update tests
- implemented _apply_index()


=== Products/PathIndexNG/PathIndexNG.py 1.1 => 1.2 ===
--- Products/PathIndexNG/PathIndexNG.py:1.1	Sat Jan 24 11:48:50 2004
+++ Products/PathIndexNG/PathIndexNG.py	Sat Jan 24 12:14:15 2004
@@ -20,7 +20,7 @@
 from OFS.SimpleItem import SimpleItem
 from BTrees.IOBTree import IOBTree
 from BTrees.OOBTree import OOBTree
-from BTrees.IIBTree import IITreeSet, intersection, union
+from BTrees.IIBTree import IITreeSet, IISet, multiunion
 from BTrees.Length import Length
 from zLOG import LOG, ERROR
 
@@ -28,8 +28,6 @@
 from Products.PluginIndexes.common.util import parseIndexRequest
 from Products.PluginIndexes.common import safe_callable
 
-_marker = []
-
 class PathIndexNG(Persistent, SimpleItem):
     """ An efficient ZCatalog index to store path components
         of persistent objects.
@@ -45,8 +43,7 @@
          'help': ('PathIndexNG', 'PathIndexNG_Settings.stx')},
     )
 
-    query_options = ('query', 'operator')
-    use_operator = 'or'
+    query_options = ()
 
     def __init__(self,id, caller=None):
         self.id = id
@@ -140,6 +137,22 @@
             return self._unindex[docid]
         except:
             return default
+
+    def _apply_index(self, request, cid=''):
+        """ search """
+
+        record = parseIndexRequest(request,self.id,self.query_options)
+        if not record.keys: return None
+
+        query_path = record.keys[0]
+        query_paths = self._index.keys(query_path, query_path + chr(255))  
+        result_set = multiunion([self._index[path] for path in query_paths]) 
+
+        if result_set:
+            return result_set, (self.id,)
+        else:
+            return IISet(), (self.id,)
+
 
     index_html = DTMLFile('dtml/index', globals())
     manage_workspace = DTMLFile('dtml/managePathIndexNG', globals())




More information about the Zope-CVS mailing list