[Checkins] SVN: zope.index/branches/nadako-sorting/ Remove write-on-read Set migrating in FilteredSets, instead document it in CHANGES.txt.

Dan Korostelev nadako at gmail.com
Mon Dec 29 06:29:30 EST 2008


Log message for revision 94413:
  Remove write-on-read Set migrating in FilteredSets, instead document it in CHANGES.txt.

Changed:
  U   zope.index/branches/nadako-sorting/CHANGES.txt
  U   zope.index/branches/nadako-sorting/src/zope/index/topic/filter.py
  U   zope.index/branches/nadako-sorting/src/zope/index/topic/tests/test_topicindex.py

-=-
Modified: zope.index/branches/nadako-sorting/CHANGES.txt
===================================================================
--- zope.index/branches/nadako-sorting/CHANGES.txt	2008-12-29 10:53:38 UTC (rev 94412)
+++ zope.index/branches/nadako-sorting/CHANGES.txt	2008-12-29 11:29:30 UTC (rev 94413)
@@ -13,17 +13,22 @@
 - Add an ``apply`` method for KeywordIndex/TopicIndex, making them
   implement IIndexSearch that can be useful in catalog.
 
-- Make KeywordIndex/TopicIndex use IFSets instead of IISets. This makes
-  it more compatible with other indexes.
-  
-  IMPORTANT: This change can lead to problems, if your code somehow
-  depends on the II nature of sets, as it was before. Also, FilteredSets
-  have IISets pickled, their ``getIds`` method now checks if it's still
-  IISet and repickles it as IFSet.
-
 - Optimize the ``search`` method of KeywordIndex/TopicIndex by using
   multiunion for the ``or`` operator and sorting before intersection for ``and``.
 
+- IMPORTANT: KeywordIndex/TopicIndex now use IFSets instead of IISets.
+  This makes it more compatible with other indexes (for example, when
+  using in catalog). This change can lead to problems, if your code somehow
+  depends on the II nature of sets, as it was before.
+  
+  Also, FilteredSets used to use IFSets as well, if you have any
+  FilteredSets pickled in the database, you need to migrate them to
+  IFSets yourself. You can do it like that:
+  
+      filter._ids = filter.family.IF.Set(filter._ids)
+  
+  Where ``filter`` is an instance of FilteredSet.
+
 Thanks Chris McDonough of repoze for supporting and useful code.
 
 3.4.1 (2007-09-28)

Modified: zope.index/branches/nadako-sorting/src/zope/index/topic/filter.py
===================================================================
--- zope.index/branches/nadako-sorting/src/zope/index/topic/filter.py	2008-12-29 10:53:38 UTC (rev 94412)
+++ zope.index/branches/nadako-sorting/src/zope/index/topic/filter.py	2008-12-29 11:29:30 UTC (rev 94413)
@@ -62,11 +62,6 @@
         self.expr = expr
 
     def getIds(self):
-        if isinstance(self._ids, self.family.II.Set):
-            # Backward-compatibility. If there was an
-            # IISet ids, repickle it as IFSet.
-            # XXX Is that okay?
-            self._ids = self.family.IF.Set(self._ids)
         return self._ids
 
     def __repr__(self):

Modified: zope.index/branches/nadako-sorting/src/zope/index/topic/tests/test_topicindex.py
===================================================================
--- zope.index/branches/nadako-sorting/src/zope/index/topic/tests/test_topicindex.py	2008-12-29 10:53:38 UTC (rev 94412)
+++ zope.index/branches/nadako-sorting/src/zope/index/topic/tests/test_topicindex.py	2008-12-29 11:29:30 UTC (rev 94413)
@@ -46,11 +46,6 @@
             PythonFilteredSet('doc3', "context.meta_type == 'doc3'",
                               self.family))
 
-        self.index.addFilter(
-            PythonFilteredSet('compat', "context.meta_type == 'doc3'",
-                              self.family))
-        self.index._filters['compat']._ids = self.family.II.Set()
-
         self.index.index_doc(0 , O('doc0'))
         self.index.index_doc(1 , O('doc1'))
         self.index.index_doc(2 , O('doc1'))
@@ -134,11 +129,6 @@
         self._apply(['doc2'], [3,4])
         self._apply(['doc1','doc2'], [])
 
-    def test_compat(self):
-        result = self.index.search('compat')
-        self.assert_(isinstance(result, self.family.IF.Set))
-        self.assertEqual(result.keys(), [5, 6])
-
 class TopicIndexTest64(TopicIndexTest):
 
     family = BTrees.family64



More information about the Checkins mailing list