[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ObjectHub - IObjectHub.py:1.2 ObjectHub.py:1.2 configure.zcml:1.2

Steve Alexander steve@cat-box.net
Mon, 11 Nov 2002 03:35:28 -0500


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

Modified Files:
	IObjectHub.py ObjectHub.py configure.zcml 
Log Message:
Code formatting changed to be closer to the zope3 style.
Removed extraneous imports.



=== Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IObjectHub.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IObjectHub.py:1.1	Tue Oct 29 22:47:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/IObjectHub.py	Mon Nov 11 03:35:28 2002
@@ -108,7 +108,6 @@
         '/whatever/whatever2'
         
         If there is no hub id, raise Zope.Exceptions.NotFoundError.
-        
         """
         
     def getLocation(hubid):
@@ -134,8 +133,7 @@
         """
 
     def unregister(obj_or_loc_or_hubid):
-        """Unregister an object by wrapped object, by location, or by
-        hubid.
+        """Unregister an object by wrapped object, by location, or by hubid.
 
         It also emits a HubIdObjectUnregisteredEvent. 
         If the hub id or location wasn't registered a 


=== Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/ObjectHub.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/ObjectHub.py:1.1	Tue Oct 29 22:47:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/ObjectHub.py	Mon Nov 11 03:35:28 2002
@@ -17,8 +17,6 @@
 $Id$
 """
 
-from Zope.App.OFS.Services.LocalEventService.LocalServiceSubscribable \
-     import LocalServiceSubscribable
 from Zope.App.OFS.Services.LocalEventService.ProtoServiceEventChannel \
      import ProtoServiceEventChannel
 
@@ -28,12 +26,11 @@
 from HubEvent import ObjectModifiedHubEvent
 from HubEvent import ObjectMovedHubEvent
 from HubEvent import ObjectRemovedHubEvent
-from IHubEvent import IHubEvent
 
 from Zope.Exceptions import NotFoundError
 
 from Zope.Event.IObjectEvent import IObjectRemovedEvent, IObjectEvent
-from Zope.Event.IObjectEvent import IObjectMovedEvent, IObjectAddedEvent
+from Zope.Event.IObjectEvent import IObjectMovedEvent
 from Zope.Event.IObjectEvent import IObjectModifiedEvent
 
 from Persistence.BTrees.IOBTree import IOBTree
@@ -48,6 +45,7 @@
 from Zope.ComponentArchitecture import getAdapter
 
 import random
+
 def randid():
     # Return a random number between -2*10**9 and 2*10**9, but not 0.
     abs = random.randrange(1, 2000000001)
@@ -76,13 +74,11 @@
     # with moving LocalEventChannel.notify to this _notify via a simple
     # assignment, i.e. _notify = LocalEventChannel.notify
     def _notify(clean_self, wrapped_self, event):
-        
         subscriptionses = clean_self.subscriptionsForEvent(event)
         # that's a non-interface shortcut for
         # subscriptionses = clean_self._registry.getAllForObject(event)
 
         for subscriptions in subscriptionses:
-            
             for subscriber, filter in subscriptions:
                 if filter is not None and not filter(event):
                     continue
@@ -120,13 +116,10 @@
                         canonical_new_location,
                         event.object)
                     clean_self._notify(wrapped_self, event)
-            
             else: 
-                
                 canonical_location = locationAsUnicode(event.location)
                 hubid = clean_self._lookupHubId(canonical_location)
                 if hubid is not None:
-                    
                     if IObjectModifiedEvent.isImplementedBy(event):
                         # send out IObjectModifiedHubEvent to plugins
                         event = ObjectModifiedHubEvent(
@@ -135,7 +128,6 @@
                             canonical_location,
                             event.object)
                         clean_self._notify(wrapped_self, event)
-
                     elif IObjectRemovedEvent.isImplementedBy(event):
                         del clean_self.__hubid_to_location[hubid]
                         del clean_self.__location_to_hubid[canonical_location]
@@ -181,7 +173,7 @@
             location = getPhysicalPathString(location)
         else:
             obj = None
-        canonical_location=locationAsUnicode(location)
+        canonical_location = locationAsUnicode(location)
         if not location.startswith(u'/'):
             raise ValueError("Location must be absolute")
         location_to_hubid = clean_self.__location_to_hubid
@@ -200,7 +192,6 @@
             obj)
         clean_self._notify(wrapped_self, event)
         return hubid
-    
     register = ContextMethod(register)
     
     def unregister(wrapped_self, location):
@@ -209,16 +200,16 @@
         if isWrapper(location):
             location = getPhysicalPathString(location)
         elif isinstance(location, int):
-            canonical_location=clean_self.getLocation(location)
+            canonical_location = clean_self.getLocation(location)
         else:
-            canonical_location=locationAsUnicode(location)
+            canonical_location = locationAsUnicode(location)
         location_to_hubid = clean_self.__location_to_hubid
         hubid_to_location = clean_self.__hubid_to_location
         try:
             hubid = location_to_hubid[canonical_location]
         except KeyError:
-            raise NotFoundError, 'location %s is not in object hub' % \
-                canonical_location
+            raise NotFoundError('location %s is not in object hub' % 
+                canonical_location)
         else:
             del hubid_to_location[hubid]
             del location_to_hubid[canonical_location]
@@ -229,18 +220,18 @@
                 hubid,
                 canonical_location)
             clean_self._notify(wrapped_self, event)
-    
     unregister = ContextMethod(unregister)
     
     ############################################################
 
     def _generateHubId(self, location):
-        index=getattr(self, '_v_nextid', 0)
-        if index%4000 == 0: index = randid()
-        hubid_to_location=self.__hubid_to_location
+        index = getattr(self, '_v_nextid', 0)
+        if index%4000 == 0:
+            index = randid()
+        hubid_to_location = self.__hubid_to_location
         while not hubid_to_location.insert(index, location):
-            index=randid()
-        self._v_nextid=index+1
+            index = randid()
+        self._v_nextid = index + 1
         return index
 
     def _lookupHubId(self, location):


=== Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/configure.zcml 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/configure.zcml:1.1	Tue Oct 29 22:47:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/configure.zcml	Mon Nov 11 03:35:28 2002
@@ -4,31 +4,36 @@
    xmlns:service='http://namespaces.zope.org/service'
 >
 
-<serviceType id='ObjectHub' 
-             interface='.IObjectHub.' />
+<serviceType
+    id='ObjectHub' 
+    interface='.IObjectHub.' />
 
-  <content class='.ObjectHub.'>
+<content class='.ObjectHub.'>
+  <factory
+      id='ObjectHub'
+      permission='Zope.ManageServices' />
+  <require
+      permission="Zope.View"
+      attributes="notify lookupRuid lookupLocation getObject
+                  register unregister" />
+  <require
+      permission="Zope.ManageServices"
+      attributes="bound unbound subscribe unsubscribe subscribeOnBind
+                  unsubscribedFrom subscribedTo" />
+</content>
 
-    <factory
-        id='ObjectHub'
-        permission='Zope.ManageServices' />
-
-    <require
-        permission="Zope.View"
-        attributes="notify lookupRuid lookupLocation getObject register unregister" />
-    <require
-        permission="Zope.ManageServices"
-        attributes="bound unbound subscribe unsubscribe subscribeOnBind
-                    unsubscribedFrom subscribedTo" />
-  </content>
-
-  <browser:menuItem menu="add_component" for="Zope.App.OFS.Container.IAdding."
-     action="ObjectHub"  title='ObjectHub'
-     description='An object hub, for cataloging, unique object ids, and more: use sparingly' />
+<browser:menuItem
+    menu="add_component"
+    for="Zope.App.OFS.Container.IAdding."
+    action="ObjectHub"
+    title='ObjectHub'
+    description='An object hub, for cataloging, unique object ids, and more: use sparingly' />
   
-  <browser:icon name="zmi_icon" for=".IObjectHub." 
-                file="./objecthub.gif" />
+<browser:icon
+    name="zmi_icon"
+    for=".IObjectHub." 
+    file="./objecthub.gif" />
 
-  <include package=".Views" />
+<include package=".Views" />
 
 </zopeConfigure>