You are not logged in Log in Join
You are here: Home » Collectors » NEW Zope.org (the website) » Patch for making PathIndex sortable » PathIndex.patch

Log in
Name

Password

 

PathIndex.patch

PathIndex (in PluggableIndexes) is not sortable because it doesn't inherit from the PluggableIndexes/common/UnIndex.py (like FieldIndex etc do). I can see no bvious reason why it couldn't be sortable hoewver as it still implements inverse lookups using self._unindex which is an IOBTree. I have produced a patch and attach it here. Unit tests ran fine and when using it, PathIndex won't barf when you supply the "sort_on" attribute to a catalog search on on this index. Could this be considered for inclusion into the next zope release?
File details
Size
1 K
File type
text/x-patch

File contents

--- lib/python/Products/PluginIndexes/PathIndex/PathIndex.py.orig	2006-02-16 13:09:09.000000000 +0800
+++ lib/python/Products/PluginIndexes/PathIndex/PathIndex.py	2006-02-16 13:18:10.000000000 +0800
@@ -31,6 +31,7 @@
 from Products.PluginIndexes.common.util import parseIndexRequest
 from Products.PluginIndexes.interfaces import IPathIndex
 from Products.PluginIndexes.interfaces import IUniqueValueIndex
+from Products.PluginIndexes.interfaces import ISortIndex
 
 _marker = []
 LOG = getLogger('Zope.PathIndex')
@@ -52,8 +53,9 @@
       'all docids with this path component on this level'
     """
 
-    __implements__ = (PluggableIndex.UniqueValueIndex,)
-    implements(IPathIndex, IUniqueValueIndex)
+    __implements__ = (PluggableIndex.UniqueValueIndex,
+                      PluggableIndex.SortIndex)
+    implements(IPathIndex, IUniqueValueIndex, ISortIndex)
 
     meta_type="PathIndex"
 
@@ -266,6 +268,13 @@
         except KeyError:
             # XXX Why is default ignored?
             return None
+    
+    def keyForDocument(self, id):
+        # This method is superceded by documentToKeyMap
+        return self._unindex[id]
+
+    def documentToKeyMap(self):
+        return self._unindex
 
     index_html = DTMLFile('dtml/index', globals())
     manage_workspace = DTMLFile('dtml/managePathIndex', globals())