Commits

pfw committed 2af19c6

durus.py - Index class for BTree used as index, initialise the index as an Index instance

Comments (0)

Files changed (1)

flaskext/durus.py

 
         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):
     """
 
                 key=tuple(key)
                 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