pfw  committed 2af19c6 - Index class for BTree used as index, initialise the index as an Index instance

  • Participants
  • Parent commits 0ba9ca0

Comments (0)

Files changed (1)

File flaskext/

         return """<html><head><title>%s</title></head><body><div>%s</div><div>%s</div></body></html>""" % (repr(value).replace('<', '&lt;').replace('>','&gt;'), repr(value).replace('<', '&lt;').replace('>','&gt;'), format(persistent_vars(value)))
+class Index(BTree):
+    def _with_limit(self, method, *args,  **kws):
+        """
+        Overload this so that only the item returned is the object as the last item in the index key.
+        """
+        for key, value in BTree._with_limit(self, method, *args, **kws):
+            yield key[-1]
 class IndexedKeyed(Keyed):
                 print "key [%s]" % str(key)
-                self._keep._indexes.setdefault(name, BTree())[key] = None
+                self._keep._indexes.setdefault(name, Index())[key] = None
                 # store pointer back into index
                 self._indexes[name] = key