[Zope3-checkins] SVN: Zope3/branches/jim-index/src/zope/app/catalog/ Commented out some things so that the tests do not bail with ImportErrors.

Gintautas Miliauskas gintas at pov.lt
Sat Jun 12 05:03:00 EDT 2004


Log message for revision 25376:
Commented out some things so that the tests do not bail with ImportErrors.



-=-
Modified: Zope3/branches/jim-index/src/zope/app/catalog/catalog.py
===================================================================
--- Zope3/branches/jim-index/src/zope/app/catalog/catalog.py	2004-06-12 08:52:20 UTC (rev 25375)
+++ Zope3/branches/jim-index/src/zope/app/catalog/catalog.py	2004-06-12 09:03:00 UTC (rev 25376)
@@ -23,60 +23,60 @@
 from zope.index.interfaces import ISimpleQuery
 
 from zope.app.zapi import getService
-from zope.app.servicenames import HubIds
-from zope.app.event.interfaces import ISubscriber
 from zope.app.annotation.interfaces import IAttributeAnnotatable
 from zope.app.utility.interfaces import ILocalUtility
 from zope.app.container.interfaces import IContainer
 
-import zope.app.hub.interfaces as IHub
-import zope.app.hub as Hub
+### import zope.app.hub.interfaces as IHub
+### import zope.app.hub as Hub
+from zope.app.uniqueid.interfaces import IUniqueIdUtility
 from zope.app.container.sample import SampleContainer
 from zope.app.catalog.interfaces.catalog import ICatalog
 
 class ResultSet:
     "Lazily accessed set of objects"
 
-    def __init__(self, hubidset, hub):
-        self.hubidset = hubidset
-        self.hub = hub
+    def __init__(self, uids, uidutil):
+        self.uids = uids
+        self.uidutil = uidutil
 
     def __len__(self):
-        return len(self.hubidset)
+        return len(self.uids)
 
     def __iter__(self):
-        for hubid in self.hubidset:
-            obj = self.hub.getObject(hubid)
-            yield obj
+        for uid in self.uids:
+            obj = self.uidutil[uid]
+            yield obj()
 
-class CatalogBaseAddSubscriber:
+### class CatalogBaseAddSubscriber:
+### 
+###     implements(ISubscriber)
+### 
+###     def __init__(self, catalog, event):
+###         self.catalog = catalog
+### 
+###     def notify(self, event):
+###         """Receive notification of add events."""
+###         self.catalog.subscribeEvents(update=False)
+### 
+### class CatalogBaseRemoveSubscriber:
+### 
+###     implements(ISubscriber)
+### 
+###     def __init__(self, catalog, event):
+###         self.catalog = catalog
+### 
+###     def notify(self, event):
+###         """Receive notification of remove events."""
+###         if self.catalog.getSubscribed():
+###             self.catalog.unsubscribeEvents()
 
-    implements(ISubscriber)
-
-    def __init__(self, catalog, event):
-        self.catalog = catalog
-
-    def notify(self, event):
-        """Receive notification of add events."""
-        self.catalog.subscribeEvents(update=False)
-
-class CatalogBaseRemoveSubscriber:
-
-    implements(ISubscriber)
-
-    def __init__(self, catalog, event):
-        self.catalog = catalog
-
-    def notify(self, event):
-        """Receive notification of remove events."""
-        if self.catalog.getSubscribed():
-            self.catalog.unsubscribeEvents()
-
 class CatalogBase(Persistent, SampleContainer):
 
-    implements(ICatalog, ISubscriber, IContainer, IAttributeAnnotatable)
+    implements(ICatalog, IContainer, IAttributeAnnotatable)
 
-    _subscribed = False
+###     implements(ISubscriber)
+###    _subscribed = False
 
     def _newContainerData(self):
         return PersistentDict()
@@ -150,8 +150,10 @@
                 # nothing left, short-circuit
                 break
         # Next we turn the IISet of hubids into a generator of objects
-        objectHub = getService(HubIds)
-        results = ResultSet(pendingResults, objectHub)
+###        objectHub = getService(HubIds)
+###        results = ResultSet(pendingResults, objectHub)
+        uidutil = getUtility(IUniqueIdUtility)
+        results = ResultSet(pendingResults, uidutil)
         return results
 
 class CatalogUtility(CatalogBase):

Modified: Zope3/branches/jim-index/src/zope/app/catalog/interfaces/index.py
===================================================================
--- Zope3/branches/jim-index/src/zope/app/catalog/interfaces/index.py	2004-06-12 08:52:20 UTC (rev 25375)
+++ Zope3/branches/jim-index/src/zope/app/catalog/interfaces/index.py	2004-06-12 09:03:00 UTC (rev 25376)
@@ -14,10 +14,10 @@
 """
 $Id$
 """
-from zope.app.event.interfaces import ISubscriber
+### from zope.app.event.interfaces import ISubscriber
 from zope.interface import Interface
 
-class ICatalogIndexUpdate(ISubscriber):
+class ICatalogIndexUpdate(Interface): ### ISubscriber
     "A wrapper around an Index that's in a Catalog"
 
     def clear():

Modified: Zope3/branches/jim-index/src/zope/app/catalog/tests.py
===================================================================
--- Zope3/branches/jim-index/src/zope/app/catalog/tests.py	2004-06-12 08:52:20 UTC (rev 25375)
+++ Zope3/branches/jim-index/src/zope/app/catalog/tests.py	2004-06-12 09:03:00 UTC (rev 25376)
@@ -23,40 +23,44 @@
 
 from zope.interface import implements
 from zope.app.index.interfaces.field import IUIFieldCatalogIndex
-from zope.app.event.interfaces import ISubscriber
-from zope.app.hub.interfaces import IObjectHub
+### from zope.app.event.interfaces import ISubscriber
+### from zope.app.hub.interfaces import IObjectHub
 from zope.app.catalog.interfaces.index import ICatalogIndex
 from zope.index.interfaces import ISimpleQuery
 from zope.app.site.interfaces import ISite
 from zope.app import zapi
 
 from zope.app.catalog.catalog import Catalog
-from zope.app.catalog.catalog import CatalogBaseAddSubscriber
-from zope.app.catalog.catalog import CatalogBaseRemoveSubscriber
+### from zope.app.catalog.catalog import CatalogBaseAddSubscriber
+### from zope.app.catalog.catalog import CatalogBaseRemoveSubscriber
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.component import getGlobalServices
-from zope.app.servicenames import HubIds
+### from zope.app.servicenames import HubIds
 from BTrees.IIBTree import IISet
 
-from zope.app.index.tests.test_objectretrievingprocessor import FakeObjectHub
+### from zope.app.index.tests.test_objectretrievingprocessor import FakeObjectHub
 
-import zope.app.hub as Hub
+### import zope.app.hub as Hub
 
-regEvt = Hub.ObjectRegisteredHubEvent
-unregEvt = Hub.ObjectUnregisteredHubEvent
-modEvt = Hub.ObjectModifiedHubEvent
+#XXX XXX XXX these will need to be changed XXX XXX XXX
+### regEvt = Hub.ObjectRegisteredHubEvent
+### unregEvt = Hub.ObjectUnregisteredHubEvent
+### modEvt = Hub.ObjectModifiedHubEvent
 
-class CFakeObjectHub(FakeObjectHub):
-    def iterObjectRegistrations(self):
-        def gen(things):
-            for hubid, obj in things:
-                loc = "/%s"%hubid
-                yield loc,hubid,obj
-        return gen(self.data.items())
+#XXX XXX XXX this will probably need to be reimplemented XXX XXX XXX
+class CFakeObjectHub: pass
+#class CFakeObjectHub(FakeObjectHub):
+#    def iterObjectRegistrations(self):
+#        def gen(things):
+#            for hubid, obj in things:
+#                loc = "/%s"%hubid
+#                yield loc,hubid,obj
+#        return gen(self.data.items())
 
 
-class StubIndex(object):
-    implements(ISimpleQuery, ISubscriber, ICatalogIndex, IUIFieldCatalogIndex)
+class StubIndex:
+    implements(ISimpleQuery, ICatalogIndex, IUIFieldCatalogIndex)
+    ### implements (ISubscriber)
 
     def __init__(self, field_name, interface=None):
         self._field_name = field_name
@@ -74,7 +78,8 @@
         for e in self._notifies:
             ob = e.object
             term = getattr(e.object ,self._field_name, '')
-            d.setdefault(term, []).append(e.hubid)
+###            d.setdefault(term, []).append(e.hubid)
+            d.setdefault(term, []).append(e.uid)
         return d
 
     def query(self, term, start=0, count=None):
@@ -82,7 +87,7 @@
         res = termdict.get(term, [])
         return IISet(res)
 
-class stoopid(object):
+class stoopid:
     def __init__(self, **kw):
         self.__dict__ = kw
 
@@ -93,18 +98,18 @@
 
     def subscribeEvents(self, update=False):
         self.subscribed = True
-        
+
     def getSubscribed(self):
         return self.subscribed
 
     def unsubscribeEvents(self):
         self.subscribed = False
-        
+
 class TestEventAdapters:
     def test_addNotify(self):
         """
         First we create a dummy catalog and an adapter for it.
-        
+
         >>> catalog = DummyCatalog()
         >>> adapter = CatalogBaseAddSubscriber(catalog, None)
 
@@ -115,11 +120,11 @@
         >>> catalog.getSubscribed()
         True
         """
-    
+
     def test_deleteNotify(self):
         """
         First we create a dummy catalog and an adapter for it.
-        
+
         >>> catalog = DummyCatalog()
         >>> adapter = CatalogBaseAddSubscriber(catalog, None)
 
@@ -180,8 +185,8 @@
     def _frob_objecthub(self, ints=1, apes=1):
         hub = CFakeObjectHub()
         service_manager = getGlobalServices()
-        service_manager.defineService(HubIds, IObjectHub)
-        service_manager.provideService(HubIds, hub)
+###        service_manager.defineService(HubIds, IObjectHub)
+###        service_manager.provideService(HubIds, hub)
         # whack some objects in our little objecthub
         if ints:
             for i in range(10):




More information about the Zope3-Checkins mailing list