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

Johan Dahlin jdahlin at async.com.br
Mon Mar 3 14:57:30 BRST 2003


mån 2003-03-03 klockan 14.55 skrev Christian Reis:
> On Tue, Feb 11, 2003 at 07:19:50PM -0200, Johan Dahlin wrote:
> > > Tested here -- I changed just index_item and unindex itme as follows:
> > >     def index_item(self, value, object):
> > >         index = self._index
> > >         if not index.has_key(value):
> > >             index[value] = []            
> > >         elif self._unique:
> > >             raise UniqueError
> > >         idx = index[value]
> > > 
> > >         # Check for duplicates
> > >         if not object in idx:
> > >             idx.append(object)
> > >             index[value] = idx
> > >         else:
> > >             # we already had that in the db :(
> > >             pass
> > >             
> > >     def unindex_item(self, value, object):
> > >         index = self._index
> > > 
> > >         current = index[value]
> > >         current.remove(object)
> > >         index[value] = current
> > > 
> > >         # If it's an empty list, remove if from the index
> > >         if not current:
> > >             del index[value]
> > 
> > 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.

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



More information about the IndexedCatalog mailing list