[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ObjectHub - IHubEventChannel.py:1.1 IObjectHub.py:1.4 ObjectHub.py:1.4

Steve Alexander steve@cat-box.net
Fri, 29 Nov 2002 10:51:04 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ObjectHub
In directory cvs.zope.org:/tmp/cvs-serv28953/lib/python/Zope/App/OFS/Services/ObjectHub

Modified Files:
	IObjectHub.py ObjectHub.py 
Added Files:
	IHubEventChannel.py 
Log Message:
Renamed registrations method to getRegistrations.
Added IHubEventChannel, for use by indexes. This is the basic interface
for filtering event channels that lie between an ObjectHub and an index.
They have a method iterObjectRegistrations for bootstrapping an index with
appropriate, yet filtered, data.


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IHubEventChannel.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
"""

Revision information:
$Id: IHubEventChannel.py,v 1.1 2002/11/29 15:51:03 stevea Exp $
"""

from Zope.Event.IEventChannel import IEventChannel

class IHubEventChannel(IEventChannel):
    """Event channel that filters hub events.

    It typically lies between the ObjectHub service and an index, so that
    only certain content gets indexed. The extra iterObjectRegistrations
    method is needed for bootstrapping the index with the appropriate objects.
    """

    def iterObjectRegistrations():
        """Returns an iterator of the object registrations.

        An object registration a tuple (location, hib_id, wrapped_object).
        """



=== Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IObjectHub.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IObjectHub.py:1.3	Tue Nov 26 14:02:49 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IObjectHub.py	Fri Nov 29 10:51:03 2002
@@ -17,12 +17,12 @@
 $Id$
 """
 
-from Zope.Event.IEventChannel import IEventChannel
+from IHubEventChannel import IHubEventChannel
 
 class ObjectHubError(Exception):
     pass
 
-class IObjectHub(IEventChannel):
+class IObjectHub(IHubEventChannel):
     """ObjectHub.
     
     Receives Object Modify Events from the Event Service, and
@@ -146,7 +146,7 @@
         """Returns the number of location<-->hubid registrations held.
         """
 
-    def registrations(location='/'):
+    def getRegistrations(location='/'):
         """Returns a sequence of the registrations at and within the
         given location.
 


=== Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/ObjectHub.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/ObjectHub.py:1.3	Tue Nov 26 14:02:49 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/ObjectHub.py	Fri Nov 29 10:51:03 2002
@@ -17,6 +17,7 @@
 $Id$
 """
 
+from __future__ import generators
 from Zope.App.OFS.Services.LocalEventService.ProtoServiceEventChannel \
      import ProtoServiceEventChannel
 
@@ -161,10 +162,10 @@
         except KeyError:
             raise NotFoundError(hubid)
     
-    def getObject(self, hubid):
+    def getObject(wrapped_self, hubid):
         '''See interface IObjectHub'''
-        location = self.getLocation(hubid)
-        adapter = getAdapter(self, ITraverser)
+        location = wrapped_self.getLocation(hubid)
+        adapter = getAdapter(wrapped_self, ITraverser)
         return adapter.traverse(location)
     getObject = ContextMethod(getObject)
     
@@ -241,7 +242,7 @@
         # assert len(self.__hubid_to_location)==len(self.__location_to_hubid)
         return len(self.__hubid_to_location)
 
-    def registrations(self, location=(u'',)):
+    def getRegistrations(self, location=(u'',)):
         """See interface IObjectHub"""
         # Location can be an ascii string a unicode or a tuple of strings
         # or unicodes. So, get a canonical location first of all.
@@ -256,6 +257,13 @@
         # be larger than any other. I could also use a type that
         # sorts after unicodes.
         return self.__location_to_hubid.items(location, location+(u'\uffff',))
+
+    def iterObjectRegistrations(wrapped_self):
+        """See interface IHubEventChannel"""
+        traverser = getAdapter(wrapped_self, ITraverser)
+        for location, hubId in wrapped_self.getRegistrations():
+            yield (location, hubId, traverser.traverse(location))
+    iterObjectRegistrations = ContextMethod(iterObjectRegistrations)
 
     ############################################################