[Zope-Checkins] CVS: Zope2 - UnIndex.py:1.23.2.6

Jim Fulton jim@digicool.com
Fri, 16 Mar 2001 18:14:50 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/SearchIndex
In directory korak:/tmp/cvs-serv21595

Modified Files:
      Tag: zope-2_3-branch
	UnIndex.py 
Log Message:
Fixed to take account of the posibility of some new data structures
mixed with old.

Need to copy length value to __len__.



--- Updated File UnIndex.py in package Zope2 --
--- UnIndex.py	2001/03/16 08:48:52	1.23.2.5
+++ UnIndex.py	2001/03/16 23:14:50	1.23.2.6
@@ -171,10 +171,17 @@
         _index=self._index
         self._index=OOBTree()
         
-        def convertSet(s, IITreeSet=IITreeSet):
+        def convertSet(s,
+                       IITreeSet=IITreeSet, IntType=type(0),
+                       type=type, len=len,
+                       doneTypes = (IntType, IITreeSet)):
+
+            if type(s) in doneTypes: return s
+
             if len(s) == 1:
                 try: return s[0]  # convert to int
                 except: pass # This is just an optimization.
+
             return IITreeSet(s)
     
         convert(_index, self._index, threshold, convertSet)
@@ -183,7 +190,7 @@
         self._unindex=IOBTree()
         convert(_unindex, self._unindex, threshold)
 
-        self.__len__=BTrees.Length.Length()
+        self.__len__=BTrees.Length.Length(len(_index))
 
     def __nonzero__(self):
         return not not self._unindex