[Zope3-checkins] CVS: Zope3/src/zope/app/services - auth.py:1.19.24.2 configure.zcml:1.56.6.2 error.py:1.2.6.2 folder.py:1.13.6.3 hub.py:1.20.8.2 menu.py:1.6.4.3 pagefolder.py:1.13.18.3 registration.py:1.14.4.4 service.py:1.29.18.2 utility.zcml:1.5.4.1

Jim Fulton jim at zope.com
Fri Sep 12 15:16:04 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv13470/src/zope/app/services

Modified Files:
      Tag: parentgeddon-branch
	auth.py configure.zcml error.py folder.py hub.py menu.py 
	pagefolder.py registration.py service.py utility.zcml 
Log Message:
Can't have the tests passing, can we?

=== Zope3/src/zope/app/services/auth.py 1.19.24.1 => 1.19.24.2 ===
--- Zope3/src/zope/app/services/auth.py:1.19.24.1	Mon Sep  8 14:21:47 2003
+++ Zope3/src/zope/app/services/auth.py	Fri Sep 12 15:15:33 2003
@@ -108,7 +108,7 @@
         'see IItemContainer'
         return self._usersbyid[id]
 
-    def setObject(self, key, object):
+    def __setitem__(self, key, object):
         'See IWriteContainer'
         # XXX I think this should generate an id if blank is passed. (RDM)
         if not isinstance(key, (str, unicode)):


=== Zope3/src/zope/app/services/configure.zcml 1.56.6.1 => 1.56.6.2 ===
--- Zope3/src/zope/app/services/configure.zcml:1.56.6.1	Mon Sep  8 14:21:47 2003
+++ Zope3/src/zope/app/services/configure.zcml	Fri Sep 12 15:15:33 2003
@@ -54,7 +54,7 @@
       />
   <require
       permission="zope.ManageServices"
-      interface="zope.app.interfaces.container.IDeleteNotifiable"
+      interface="zope.app.interfaces.container.IRemoveNotifiable"
       />
 </content>
 
@@ -80,7 +80,7 @@
       />
   <require
       permission="zope.ManageServices"
-      interface="zope.app.interfaces.container.IDeleteNotifiable"
+      interface="zope.app.interfaces.container.IRemoveNotifiable"
       />
 </content>
 
@@ -92,7 +92,7 @@
       />
   <require
       permission="zope.ManageServices"
-      interface="zope.app.interfaces.container.IDeleteNotifiable"
+      interface="zope.app.interfaces.container.IRemoveNotifiable"
       />
 </content>
 
@@ -221,7 +221,7 @@
         />
     <require
         permission="zope.ManageServices"
-        interface="zope.app.interfaces.container.IDeleteNotifiable"
+        interface="zope.app.interfaces.container.IRemoveNotifiable"
         />
 
   </content>
@@ -290,7 +290,8 @@
         interface="
         zope.app.interfaces.container.IWriteContainer
         zope.app.interfaces.services.registration.IOrderedContainer
-        zope.app.interfaces.container.IDeleteNotifiable
+        zope.app.interfaces.container.IRemoveNotifiable
+        zope.app.interfaces.container.INameChooser
         " 
         />
     <implements


=== Zope3/src/zope/app/services/error.py 1.2.6.1 => 1.2.6.2 ===
--- Zope3/src/zope/app/services/error.py:1.2.6.1	Mon Sep  8 14:21:47 2003
+++ Zope3/src/zope/app/services/error.py	Fri Sep 12 15:15:33 2003
@@ -109,11 +109,11 @@
                         login = request.user.getLogin()
                     else:
                         login = 'unauthenticated'
-                    username = ', '.join((login,
+                    username = ', '.join(map(str, (login,
                                           request.user.getId(),
                                           request.user.getTitle(),
                                           request.user.getDescription()
-                                         ))
+                                         )))
                 # When there's an unauthorized access, request.user is
                 # not set, so we get an AttributeError
                 # XXX is this right? Surely request.user should be set!


=== Zope3/src/zope/app/services/folder.py 1.13.6.2 => 1.13.6.3 ===
--- Zope3/src/zope/app/services/folder.py:1.13.6.2	Mon Sep  8 17:15:10 2003
+++ Zope3/src/zope/app/services/folder.py	Fri Sep 12 15:15:33 2003
@@ -41,7 +41,7 @@
         super(SiteManagementFolders, self).__init__()
         f = SiteManagementFolder()
         f.__name__ = 'default'
-        self.setObject('default', f)
+        self['default'] = f
 
     def queryComponent(self, type=None, filter=None, all=0):
         local = []
@@ -67,7 +67,7 @@
 
         return local
 
-    def setObject(self, name, obj):
+    def __setitem__(self, name, obj):
         if not (ISiteManagementFolder.isImplementedBy(obj)
                 or IBundle.isImplementedBy(obj)):
             raise TypeError("Can only add packages")
@@ -76,10 +76,10 @@
         if name == "Packages":
             raise ValueError("Packages is not a valid package name")
                 
-        name = super(SiteManagementFolders, self).setObject(name, obj)
+        super(SiteManagementFolders, self)[name] = obj
 
         # We want out items to be virtually contained in our container
-        # We have to do this after calling the superclass setObject
+        # We have to do this after calling the superclass __setitem__
         # otherwise, it would be overwritten.
         obj.__parent__ = self.__parent__
 


=== Zope3/src/zope/app/services/hub.py 1.20.8.1 => 1.20.8.2 ===
--- Zope3/src/zope/app/services/hub.py:1.20.8.1	Mon Sep  8 14:21:47 2003
+++ Zope3/src/zope/app/services/hub.py	Fri Sep 12 15:15:33 2003
@@ -33,8 +33,10 @@
 from zope.app.services.servicenames import EventSubscription
 
 from zope.app.interfaces.traversing import ITraverser
-from zope.app.interfaces.event import IObjectRemovedEvent, IObjectEvent
-from zope.app.interfaces.event import IObjectMovedEvent, IObjectCreatedEvent
+from zope.app.interfaces.event import IObjectEvent
+from zope.app.interfaces.container import IObjectRemovedEvent
+from zope.app.interfaces.container import IObjectMovedEvent
+from zope.app.interfaces.event import IObjectCreatedEvent
 from zope.app.interfaces.event import IObjectModifiedEvent
 from zope.app.interfaces.services.hub import IObjectHub, ObjectHubError
 from zope.app.services.event import ServiceSubscriberEventChannel
@@ -47,11 +49,11 @@
 from zope.app.interfaces.services.service import ISimpleService
 from zope.interface import implements
 from zope.app.interfaces.event import ISubscriber
-from zope.app.interfaces.event import IObjectAddedEvent
+from zope.app.interfaces.container import IObjectAddedEvent
 from zope.app.interfaces.content.folder import IFolder
 from zope.app.interfaces.traversing import ITraversable
 from zope.app.services.servicenames import HubIds
-from zope.app.event.objectevent import ObjectAddedEvent
+from zope.app.container.contained import ObjectAddedEvent
 
 from zope.app.traversing import traverse, traverseName, getPath, getRoot
 from zope.app.interfaces.services.hub import ObjectHubError
@@ -176,9 +178,12 @@
     else:
         return abs
 
-def canonicalSlash(path):
+def canonicalSlash(parent, name=None):
     # Return a canonical path, with a slash appended
-    return canonicalPath(path) + u'/'
+    path = canonicalPath(parent) + u'/'
+    if name:
+        path += name + u'/'
+    return path
 
 class ObjectHub(ServiceSubscriberEventChannel, Contained):
 
@@ -205,10 +210,11 @@
             # generate NotificationHubEvents only if object is known
             # ie registered
             if IObjectMovedEvent.isImplementedBy(event):
-                pathslash = canonicalSlash(event.fromLocation)
+                pathslash = canonicalSlash(event.oldParent, event.oldName)
                 hubid = clean_self.__path_to_hubid.get(pathslash)
                 if hubid is not None:
-                    new_pathslash = canonicalSlash(event.location)
+                    new_pathslash = canonicalSlash(
+                        event.newParent, event.newName)
                     path_to_hubid = clean_self.__path_to_hubid
                     if path_to_hubid.has_key(new_pathslash):
                         raise ObjectHubError(
@@ -230,7 +236,7 @@
                 # it.
                 pass
             else:
-                pathslash = canonicalSlash(event.location)
+                pathslash = canonicalSlash(event.newParent, event.newName)
                 hubid = clean_self.__path_to_hubid.get(pathslash)
                 if hubid is not None:
                     if IObjectModifiedEvent.isImplementedBy(event):
@@ -434,7 +440,7 @@
 
         if event.__class__ is ObjectAddedEvent:
             hub = getService(wrapped_self, HubIds)
-            wrapped_self._registerObject(event.location, hub)
+            wrapped_self._registerObject(event.object, hub)
 
     currentlySubscribed = False # Default subscription state
 


=== Zope3/src/zope/app/services/menu.py 1.6.4.2 => 1.6.4.3 ===
--- Zope3/src/zope/app/services/menu.py:1.6.4.2	Mon Sep  8 17:15:10 2003
+++ Zope3/src/zope/app/services/menu.py	Fri Sep 12 15:15:33 2003
@@ -95,14 +95,13 @@
 
         return result
 
-    def setObject(self, key, object):
-        """See zope.app.interfaces.container.Container"""
+    def addItem(self, object):
         self._next += 1
         key = str(self._next)
         while key in self:
             self._next += 1
             key = str(self._next)
-        super(LocalBrowserMenu, self).setObject(key, object)
+        super(LocalBrowserMenu, self)[key] = object
         return key
 
 


=== Zope3/src/zope/app/services/pagefolder.py 1.13.18.2 => 1.13.18.3 ===
--- Zope3/src/zope/app/services/pagefolder.py:1.13.18.2	Mon Sep  8 17:56:38 2003
+++ Zope3/src/zope/app/services/pagefolder.py	Fri Sep 12 15:15:33 2003
@@ -57,10 +57,10 @@
     ########################################################
 
 
-    def setObject(self, name, object):
+    def __setitem__(self, name, object):
         if (IRegistrationManager.isImplementedBy(object) or
             IZPTTemplate.isImplementedBy(object)):
-            name = super(PageFolder, self).setObject(name, object)
+            super(PageFolder, self)[name] = object
         else:
             raise TypeError("Can only add templates", object)
 
@@ -79,7 +79,7 @@
                 )
 
             registrations = self.getRegistrationManager()
-            id = registrations.setObject('', registration)
+            id = registrations.addRegistration(registration)
             registration = registrations[id]
             registration.status = ActiveStatus
 


=== Zope3/src/zope/app/services/registration.py 1.14.4.3 => 1.14.4.4 ===
--- Zope3/src/zope/app/services/registration.py:1.14.4.3	Tue Sep  9 10:03:10 2003
+++ Zope3/src/zope/app/services/registration.py	Fri Sep 12 15:15:33 2003
@@ -22,8 +22,7 @@
 from persistence import Persistent
 from zope.interface import implements
 from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.interfaces.container import IAddNotifiable, IDeleteNotifiable
-from zope.app.interfaces.container import IRemoveSource, INameChooser
+from zope.app.interfaces.container import IAddNotifiable, IRemoveNotifiable
 from zope.app.interfaces.dependable import IDependable, DependencyError
 from zope.app.interfaces.services import registration as interfaces
 from zope.app.interfaces.services.module import IModuleManager
@@ -32,6 +31,7 @@
 from zope.security.proxy import Proxy, trustedRemoveSecurityProxy
 from zope.proxy import getProxiedObject
 from zope.app.container.contained import Contained, contained, uncontained
+from zope.exceptions import DuplicationError
 
 class RegistrationStatusProperty(object):
 
@@ -286,12 +286,12 @@
     """Registration objects that just contain registration data
 
     Classes that derive from this must make sure they implement
-    IDeleteNotifiable either by implementing
+    IRemoveNotifiable either by implementing
     implementedBy(SimpleRegistration) or explicitly implementing
-    IDeleteNotifiable.
+    IRemoveNotifiable.
     """
 
-    implements(interfaces.IRegistration, IDeleteNotifiable,
+    implements(interfaces.IRegistration, IRemoveNotifiable,
                       # We are including this here because we want all of the
                       # subclasses to get it and we don't really need to be
                       # flexible about the policy here. At least we don't
@@ -316,22 +316,22 @@
     def implementationSummary(self):
         return ""
 
-    # Methods from IDeleteNotifiable
+    # Methods from IRemoveNotifiable
 
-    def beforeDeleteHook(self, registration, container):
-        "See IDeleteNotifiable"
+    def removeNotify(self, event):
+        "See IRemoveNotifiable"
 
-        objectstatus = registration.status
+        objectstatus = self.status
 
         if objectstatus == interfaces.ActiveStatus:
             try:
-                objectpath = zapi.getPath(registration)
+                objectpath = zapi.getPath(self)
             except: # XXX
-                objectpath = str(registration)
+                objectpath = str(self)
             raise DependencyError("Can't delete active registration (%s)"
                                   % objectpath)
         elif objectstatus == interfaces.RegisteredStatus:
-            registration.status = interfaces.UnregisteredStatus
+            self.status = interfaces.UnregisteredStatus
 
 
 class NamedRegistration(SimpleRegistration):
@@ -354,7 +354,7 @@
     of the component.
     """
 
-    # SimpleRegistration implements IDeleteNotifiable, so we don't need
+    # SimpleRegistration implements IRemoveNotifiable, so we don't need
     # it below.
     implements(interfaces.IComponentRegistration, IAddNotifiable)
 
@@ -411,29 +411,28 @@
 
         return component
 
-    def afterAddHook(self, registration, container):
+    def addNotify(self, event):
         "See IAddNotifiable"
-        component = registration.getComponent()
+        component = self.getComponent()
         dependents = zapi.getAdapter(component, IDependable)
-        objectpath = zapi.getPath(registration)
+        objectpath = zapi.getPath(self)
         dependents.addDependent(objectpath)
         # Also update usage, if supported
         adapter = zapi.queryAdapter(component, interfaces.IRegistered)
         if adapter is not None:
-            adapter.addUsage(zapi.getPath(registration))
+            adapter.addUsage(objectpath)
 
-    def beforeDeleteHook(self, registration, container):
-        "See IDeleteNotifiable"
-        super(ComponentRegistration, self).beforeDeleteHook(registration,
-                                                             container)
-        component = registration.getComponent()
+    def removeNotify(self, event):
+        "See IRemoveNotifiable"
+        super(ComponentRegistration, self).removeNotify(event)
+        component = self.getComponent()
         dependents = zapi.getAdapter(component, IDependable)
-        objectpath = zapi.getPath(registration)
+        objectpath = zapi.getPath(self)
         dependents.removeDependent(objectpath)
         # Also update usage, if supported
         adapter = zapi.queryAdapter(component, interfaces.IRegistered)
         if adapter is not None:
-            adapter.removeUsage(zapi.getPath(registration))
+            adapter.removeUsage(zapi.getPath(self))
 
 class NamedComponentRegistration(NamedRegistration, ComponentRegistration):
     """Registrations for named components.
@@ -528,8 +527,7 @@
     Manages registrations within a package.
     """
 
-    implements(interfaces.IRegistrationManager, IDeleteNotifiable,
-               INameChooser)
+    implements(interfaces.IRegistrationManager, IRemoveNotifiable)
 
     def __init__(self):
         self._data = ()
@@ -571,19 +569,20 @@
         "See IEnumerableMapping"
         return len(self._data)
 
-    def setObject(self, key, object):
+    def __setitem__(self, key, v):
+        if key in self:
+            raise DuplicationError(key)
+        self._data[key] = v
+
+    def addRegistration(self, object):
         "See IWriteContainer"
-        if not key:
-            key = self.chooseName(key, object)
-        else:
-            if key in self:
-                raise DuplicationError("key is already registered", key)
+        key = self._chooseName(key, object)
 
         object = contained(object, self, key)
         self._data += ((key, object), )
         return key
 
-    def chooseName(self, name, object):
+    def _chooseName(self, name, object):
         if not name:
             name = object.__class__.__name__
 
@@ -597,7 +596,7 @@
 
     def __delitem__(self, key):
         "See IWriteContainer"
-        uncontained(self[key])
+        uncontained(self[key], self)
         self._data = tuple(
             [item
              for item in self._data
@@ -655,11 +654,10 @@
     def moveDown(self, names):
         self._moveUpOrDown(names, 1)
 
-    def beforeDeleteHook(self, object, container):
-        assert object == self
-        container = zapi.getAdapter(object, IRemoveSource)
-        for k, v in self._data:
-            container.removeObject(k)
+    def removeNotify(self, event):
+        assert event.object == self
+        for name in self:
+            del self[name]
 
 
 class RegistrationManagerContainer(object):
@@ -673,7 +671,7 @@
         rm = RegistrationManager()
         rm.__parent__ = self
         rm.__name__ = 'RegistrationManager'
-        self.setObject(rm.__name__, rm)
+        self[rm.__name__] = rm
 
     def __delitem__(self, name):
         """Delete an item, but not if it's the last registration manager


=== Zope3/src/zope/app/services/service.py 1.29.18.1 => 1.29.18.2 ===
--- Zope3/src/zope/app/services/service.py:1.29.18.1	Mon Sep  8 14:21:47 2003
+++ Zope3/src/zope/app/services/service.py	Fri Sep 12 15:15:33 2003
@@ -214,8 +214,8 @@
     def __len__(self):
         return len(self.Packages)
 
-    def setObject(self, name, value):
-        return self.Packages.setObject(name, value)
+    def __setitem__(self, name, value):
+        self.Packages[name] = value
 
     def __delitem__(self, key):
         return self.Packages.__delitem__(key)


=== Zope3/src/zope/app/services/utility.zcml 1.5 => 1.5.4.1 ===
--- Zope3/src/zope/app/services/utility.zcml:1.5	Fri Aug 22 16:02:20 2003
+++ Zope3/src/zope/app/services/utility.zcml	Fri Sep 12 15:15:33 2003
@@ -16,7 +16,7 @@
     permission="zope.ManageServices"
     interface="zope.app.interfaces.services.utility.IUtilityRegistration
                zope.app.interfaces.container.IAddNotifiable
-               zope.app.interfaces.container.IDeleteNotifiable"
+               zope.app.interfaces.container.IRemoveNotifiable"
     set_schema="zope.app.interfaces.services.utility.IUtilityRegistration"
     />
  </content>




More information about the Zope3-Checkins mailing list