[Checkins] SVN: zc.catalog/trunk/src/zc/catalog/ Removed BTreeAPI, taking advantage of the equivalent things implemented in

Albertas Agejevas alga at pov.lt
Mon Feb 19 06:55:03 EST 2007


Log message for revision 72675:
  Removed BTreeAPI, taking advantage of the equivalent things implemented in 
  BTrees trunk.
  

Changed:
  U   zc.catalog/trunk/src/zc/catalog/__init__.py
  U   zc.catalog/trunk/src/zc/catalog/extentcatalog.py
  U   zc.catalog/trunk/src/zc/catalog/extentcatalog.txt
  U   zc.catalog/trunk/src/zc/catalog/index.py
  U   zc.catalog/trunk/src/zc/catalog/interfaces.py
  U   zc.catalog/trunk/src/zc/catalog/tests.py

-=-
Modified: zc.catalog/trunk/src/zc/catalog/__init__.py
===================================================================
--- zc.catalog/trunk/src/zc/catalog/__init__.py	2007-02-19 11:50:13 UTC (rev 72674)
+++ zc.catalog/trunk/src/zc/catalog/__init__.py	2007-02-19 11:55:00 UTC (rev 72675)
@@ -14,58 +14,3 @@
 """zc.component package
 
 """
-import BTrees.Interfaces
-import BTrees.IFBTree
-
-
-class BTreeAPI32(object):
-    """IFTree components and merge functions.
-
-    This class can be used as a pickleable reference to a particular
-    flavour of BTrees used in an index or catalog (IFBTrees in this case).
-    """
-
-    TreeSet = BTrees.IFBTree.IFTreeSet
-    Set = BTrees.IFBTree.IFSet
-    Bucket = BTrees.IFBTree.IFBucket
-
-    # IMerge
-    difference = BTrees.IFBTree.difference
-    union = BTrees.IFBTree.union
-    intersection = BTrees.IFBTree.intersection
-
-    # IIMerge
-    weightedUnion = BTrees.IFBTree.weightedUnion
-    weightedIntersection = BTrees.IFBTree.weightedIntersection
-
-    # IMergeIntegerKey
-    multiunion = BTrees.IFBTree.multiunion
-
-
-try:
-    import BTrees.LFBTree
-except:
-    pass
-else:
-    class BTreeAPI64(object):
-        """IFTree components and merge functions.
-
-        This class can be used as a pickleable reference to a particular
-        flavour of BTrees used in an index or catalog (LFBTrees in this case).
-        """
-
-        TreeSet = BTrees.LFBTree.LFTreeSet
-        Set = BTrees.LFBTree.LFSet
-        Bucket = BTrees.LFBTree.LFBucket
-
-        # IMerge
-        difference = BTrees.LFBTree.difference
-        union = BTrees.LFBTree.union
-        intersection = BTrees.LFBTree.intersection
-
-        # IIMerge
-        weightedUnion = BTrees.LFBTree.weightedUnion
-        weightedIntersection = BTrees.LFBTree.weightedIntersection
-
-        # IMergeIntegerKey
-        multiunion = BTrees.LFBTree.multiunion

Modified: zc.catalog/trunk/src/zc/catalog/extentcatalog.py
===================================================================
--- zc.catalog/trunk/src/zc/catalog/extentcatalog.py	2007-02-19 11:50:13 UTC (rev 72674)
+++ zc.catalog/trunk/src/zc/catalog/extentcatalog.py	2007-02-19 11:55:00 UTC (rev 72675)
@@ -16,7 +16,8 @@
 $Id: extentcatalog.py 3296 2005-09-09 19:29:20Z benji $
 """
 
-from BTrees import IFBTree
+import sys
+import BTrees.IFBTree
 import persistent
 from zope import interface, component
 from zope.app.catalog import catalog
@@ -34,14 +35,15 @@
     interface.implements(interfaces.IExtent)
     __parent__ = None
 
-    BTreeAPI = zc.catalog.BTreeAPI32
-
     def __init__(self):
-        self.BTreeAPI = zope.component.queryUtility(
-            interfaces.IBTreeAPI,
-            default=zc.catalog.BTreeAPI32)
-        self.set = self.BTreeAPI.TreeSet()
+        self.set = zope.component.queryUtility(
+            IFactory, name="IFTreeSet",
+            default=BTrees.IFBTree.IFTreeSet)()
 
+    @property
+    def BTreeAPI(self):
+        return sys.modules[self.set.__class__.__module__]
+
     def add(self, uid, obj):
         self.set.insert(uid)
 

Modified: zc.catalog/trunk/src/zc/catalog/extentcatalog.txt
===================================================================
--- zc.catalog/trunk/src/zc/catalog/extentcatalog.txt	2007-02-19 11:50:13 UTC (rev 72674)
+++ zc.catalog/trunk/src/zc/catalog/extentcatalog.txt	2007-02-19 11:55:00 UTC (rev 72675)
@@ -19,15 +19,16 @@
     >>> root = makeRoot()
     >>> intid = zope.component.getUtility(
     ...     zope.app.intid.interfaces.IIntIds, context=root)
-    >>> BTreeAPI = component.queryUtility(zc.catalog.interfaces.IBTreeAPI,
-    ...                                   default=zc.catalog.BTreeAPI32)
+    >>> TreeSet = component.queryUtility(zope.component.interfaces.IFactory,
+    ...                                  name="IFTreeSet",
+    ...                                  default=BTrees.IFBTree.IFTreeSet)
 
     >>> from zope.app.container.interfaces import IContained
     >>> class DummyIndex(persistent.Persistent):
     ...     interface.implements(IContained)
     ...     __parent__ = __name__ = None
     ...     def __init__(self):
-    ...         self.uids = BTreeAPI.TreeSet()
+    ...         self.uids = TreeSet()
     ...     def unindex_doc(self, uid):
     ...         if uid in self.uids:
     ...             self.uids.remove(uid)
@@ -128,7 +129,7 @@
     >>> for i in range(1, 100, 2):
     ...     extent.add(i, None)
     ...
-    >>> alt_set = BTreeAPI.TreeSet()
+    >>> alt_set = TreeSet()
     >>> alt_set.update(range(0, 166, 33)) # return value is unimportant here
     6
     >>> sorted(alt_set)

Modified: zc.catalog/trunk/src/zc/catalog/index.py
===================================================================
--- zc.catalog/trunk/src/zc/catalog/index.py	2007-02-19 11:50:13 UTC (rev 72674)
+++ zc.catalog/trunk/src/zc/catalog/index.py	2007-02-19 11:55:00 UTC (rev 72675)
@@ -15,6 +15,7 @@
 
 $Id: index.py 2918 2005-07-19 22:12:38Z jim $
 """
+import sys
 import datetime
 import pytz.reference
 import persistent
@@ -40,19 +41,23 @@
                          zc.catalog.interfaces.IIndexValues,
                          )
 
-    BTreeAPI = zc.catalog.BTreeAPI32
-
     def __init__(self):
+        self.btreemodule = component.queryUtility(
+            component.interfaces.IFactory,
+            name="IFTreeSet",
+            default=IFBTree.IFTreeSet)().__class__.__module__
+        self.IOBTree = component.queryUtility(
+            zope.component.interfaces.IFactory,
+            name='IOBTree', default=IOBTree.IOBTree)().__class__
         self.clear()
-        self.BTreeAPI = component.queryUtility(
-            zc.catalog.interfaces.IBTreeAPI,
-            default=zc.catalog.BTreeAPI32)
 
+    @property
+    def BTreeAPI(self):
+        return sys.modules[self.btreemodule]
+
     def clear(self):
         self.values_to_documents = OOBTree.OOBTree()
-        self.documents_to_values = component.queryUtility(
-            zope.component.interfaces.IFactory,
-            name='IOBTree', default=IOBTree.IOBTree)()
+        self.documents_to_values = self.IOBTree()
         self.documentCount = Length.Length(0)
         self.wordCount = Length.Length(0)
 

Modified: zc.catalog/trunk/src/zc/catalog/interfaces.py
===================================================================
--- zc.catalog/trunk/src/zc/catalog/interfaces.py	2007-02-19 11:50:13 UTC (rev 72674)
+++ zc.catalog/trunk/src/zc/catalog/interfaces.py	2007-02-19 11:55:00 UTC (rev 72675)
@@ -307,12 +307,3 @@
         title=_('Resolution'),
         default=2,
         required=True)
-
-
-class IBTreeAPI(BTrees.Interfaces.IMergeIntegerKey, BTrees.Interfaces.IIMerge):
-    """A class encapsulating a flavour (32/64 bit) of the XFBTrees"""
-
-    TreeSet = interface.Attribute("The class of a tree set flavour")
-    Set = interface.Attribute("The class of a set flavour")
-    Bucket = interface.Attribute("The class of a set flavour")
-

Modified: zc.catalog/trunk/src/zc/catalog/tests.py
===================================================================
--- zc.catalog/trunk/src/zc/catalog/tests.py	2007-02-19 11:50:13 UTC (rev 72674)
+++ zc.catalog/trunk/src/zc/catalog/tests.py	2007-02-19 11:55:00 UTC (rev 72675)
@@ -49,11 +49,10 @@
         zope.component.factory.Factory(BTrees.OLBTree.OLBTree),
         name='OIBTree')
     zope.component.provideUtility(
-        zc.catalog.BTreeAPI64,
-        provides=zc.catalog.interfaces.IBTreeAPI)
+        zope.component.factory.Factory(BTrees.LFBTree.LFTreeSet),
+        name='IFTreeSet')
 
 
-
 def tearDown64bit(test):
     zope.component.testing.tearDown(test)
 



More information about the Checkins mailing list