[ZODB-Dev] BTrees and Mutables, was Re: [IndexedCatalog] bug in default indexing

Johan Dahlin jdahlin at async.com.br
Mon Mar 3 15:09:32 BRST 2003


> > > Coolio. Basically the same code as I have in my tree now.
> > > Good that it seems to work with you.
> > > (Just a few optimizations :-)
> 
> Yes, a few weeks ago.

Err, it seems that it got lost when I moved stuff around.

Anyway, I plan to commit this patch, unless anyone object.
(More or less like Nicolas patch, but not identical)

Index: Indexes.py
===================================================================
RCS file: /cvs/IndexedCatalog/IndexedCatalog/Indexes.py,v
retrieving revision 1.66
diff -u -u -r1.66 Indexes.py
--- Indexes.py	11 Feb 2003 19:16:08 -0000	1.66
+++ Indexes.py	3 Mar 2003 18:07:41 -0000
@@ -283,11 +283,12 @@
             index[value] = []            
         elif self._unique:
             raise UniqueError
-
+        idx = index[value]
+        
         # Check for duplicates
-        if not object in index[value]:
-            index[value].append(object)
-            index._p_changed = 1
+        if not object in idx:
+            idx.append(object)
+            index[value] = idx
         else:
             # we already had that in the db :(
             pass
@@ -301,7 +302,8 @@
         # If it's an empty list, remove if from the index
         if not current:
             del index[value]
-        index._p_changed = 1
+        else:
+            index[value] = current
 
     def __lt__(self, expr):
         "Operator: > (less then)"


-- 
Johan Dahlin <jdahlin@async.com.br>
Async Open Source



More information about the IndexedCatalog mailing list