[Zope3-checkins] CVS: Zope3/src/zope/app/services - registration.py:1.29 service.py:1.42

Jim Fulton jim at zope.com
Sun Mar 7 08:54:49 EST 2004


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

Modified Files:
	registration.py service.py 
Log Message:
Got rid of (unabstracted) NameComponentRegistry.


=== Zope3/src/zope/app/services/registration.py 1.28 => 1.29 ===
--- Zope3/src/zope/app/services/registration.py:1.28	Sat Mar  6 17:20:47 2004
+++ Zope3/src/zope/app/services/registration.py	Sun Mar  7 08:54:18 2004
@@ -17,25 +17,23 @@
 """
 __metaclass__ = type
 
-from zope.app import zapi
-
 from persistent import Persistent
-from zope.interface import implements
-from zope.fssync.server.interfaces import IObjectFile
-from zope.fssync.server.entryadapter import ObjectEntryAdapter
-from zope.proxy import removeAllProxies, getProxiedObject
-from zope.security.checker import InterfaceChecker, CheckerPublic
-from zope.security.proxy import Proxy, trustedRemoveSecurityProxy
-from zope.exceptions import DuplicationError
-from zope.xmlpickle import dumps, loads
-
 from zope.app.container.contained import Contained
 from zope.app.container.contained import setitem, contained, uncontained
-from zope.app.interfaces.annotation import IAttributeAnnotatable
 from zope.app.container.interfaces import IAddNotifiable, IRemoveNotifiable
+from zope.app import zapi
+from zope.app.interfaces.annotation import IAttributeAnnotatable
 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
+from zope.exceptions import DuplicationError
+from zope.fssync.server.entryadapter import ObjectEntryAdapter
+from zope.fssync.server.interfaces import IObjectFile
+from zope.interface import implements
+from zope.proxy import removeAllProxies, getProxiedObject
+from zope.security.checker import InterfaceChecker, CheckerPublic
+from zope.security.proxy import Proxy, trustedRemoveSecurityProxy
+from zope.xmlpickle import dumps, loads
 
 
 class RegistrationStatusProperty(object):
@@ -436,52 +434,6 @@
         adapter = interfaces.IRegistered(component, None)
         if adapter is not None:
             adapter.removeUsage(zapi.getPath(self))
-
-
-class NameComponentRegistry:
-    """Mixin for implementing INameComponentRegistry
-    """
-    implements(interfaces.INameComponentRegistry)
-
-    def __init__(self, *args, **kw):
-        self._bindings = {}
-        super(NameComponentRegistry, self).__init__(*args, **kw)
-
-    def queryRegistrationsFor(self, cfg, default=None):
-        """See IRegistry"""
-        return self.queryRegistrations(cfg.name, default)
-
-    def queryRegistrations(self, name, default=None):
-        """See INameRegistry"""
-        return self._bindings.get(name, default)
-
-    def createRegistrationsFor(self, cfg):
-        """See IRegistry"""
-        return self.createRegistrations(cfg.name)
-
-    def createRegistrations(self, name):
-        """See INameRegistry"""
-        try:
-            registry = self._bindings[name]
-        except KeyError:
-            registry = RegistrationStack(self)
-            self._bindings[name] = registry
-            self._p_changed = 1
-        return registry
-
-    def listRegistrationNames(self):
-        """See INameRegistry"""
-        return filter(self._bindings.get,
-                      self._bindings.keys())
-
-    def queryActiveComponent(self, name, default=None):
-        """See INameComponentRegistry"""
-        registry = self.queryRegistrations(name)
-        if registry:
-            registration = registry.active()
-            if registration is not None:
-                return registration.getComponent()
-        return default
 
 
 from zope.app.dependable import PathSetAnnotation


=== Zope3/src/zope/app/services/service.py 1.41 => 1.42 ===
--- Zope3/src/zope/app/services/service.py:1.41	Sat Mar  6 17:07:25 2004
+++ Zope3/src/zope/app/services/service.py	Sun Mar  7 08:54:18 2004
@@ -26,46 +26,36 @@
 $Id$
 """
 
-import sys
-
 from transaction import get_transaction
 from zodbcode.module import PersistentModuleRegistry
-
-import zope.interface
-
-from zope.component import getServiceManager
-from zope.component.exceptions import ComponentLookupError
-from zope.fssync.server.entryadapter import AttrMapping, DirectoryAdapter
-from zope.proxy import removeAllProxies
-
-import zope.app.interfaces.services.registration
-from zope.app import zapi
-
-from zope.app.event.function import Subscriber
-from zope.app.interfaces.services.service import IPossibleSite
-
 from zope.app.component.nextservice import getNextService
 from zope.app.component.nextservice import getNextServiceManager
-
+from zope.app.container.btree import BTreeContainer
 from zope.app.container.constraints import ItemTypePrecondition
-
+from zope.app.container.contained import Contained
 from zope.app.container.interfaces import IContainer
+from zope.app.event.function import Subscriber
+from zope.app import zapi
 from zope.app.interfaces.services.service import IBindingAware
+from zope.app.interfaces.services.service import ILocalService
+from zope.app.interfaces.services.service import IPossibleSite
 from zope.app.interfaces.services.service import IServiceRegistration
+from zope.app.interfaces.services.service import ISite
 from zope.app.interfaces.services.service import ISiteManager
-
-from zope.app.services.registration import NameComponentRegistry
-from zope.app.services.registration import ComponentRegistration
-from zope.app.services.folder import SiteManagementFolder
-from zope.app.interfaces.services.service import ILocalService
-
-from zope.app.traversing import getPath
-from zope.app.container.contained import Contained
-from zope.app.container.btree import BTreeContainer
-
+from zope.app.interfaces.services.registration import IRegistry
 from zope.app.interfaces.traversing import IContainmentRoot
-from zope.app.interfaces.services.service import ISite
 from zope.app.location import inside
+from zope.app.services.folder import SiteManagementFolder
+from zope.app.services.registration import ComponentRegistration
+from zope.app.services.registration import RegistrationStack
+from zope.app.traversing import getPath
+from zope.component.exceptions import ComponentLookupError
+from zope.component import getServiceManager
+from zope.fssync.server.entryadapter import AttrMapping, DirectoryAdapter
+from zope.proxy import removeAllProxies
+import sys
+import zope.app.interfaces.services.registration
+import zope.interface
 
 
 class IRegistrationManagerContainerContainer(zope.interface.Interface):
@@ -74,25 +64,26 @@
         """Add a site-management folder
         """
     __setitem__.precondition = ItemTypePrecondition(
-        zope.app.interfaces.services.registration.IRegistrationManagerContainer)
+       zope.app.interfaces.services.registration.IRegistrationManagerContainer)
+
 
 class SiteManager(
     BTreeContainer,
     PersistentModuleRegistry,
-    NameComponentRegistry,
     ):
 
     zope.interface.implements(
         ISiteManager,
         IRegistrationManagerContainerContainer,
+        IRegistry,
         )
 
     def __init__(self, site):
+        self._bindings = {}
         self.__parent__ = site
         self.__name__ = '++etc++site'
         BTreeContainer.__init__(self)
         PersistentModuleRegistry.__init__(self)
-        NameComponentRegistry.__init__(self)
         self.subSites = ()
         self._setNext(site)
         self['default'] = SiteManagementFolder()
@@ -130,6 +121,39 @@
         subsites.append(sub)
         self.subSites = tuple(subsites)
 
+    def queryRegistrationsFor(self, cfg, default=None):
+        """See IRegistry"""
+        return self.queryRegistrations(cfg.name, default)
+
+    def queryRegistrations(self, name, default=None):
+        """See INameRegistry"""
+        return self._bindings.get(name, default)
+
+    def createRegistrationsFor(self, cfg):
+        """See IRegistry"""
+        return self.createRegistrations(cfg.name)
+
+    def createRegistrations(self, name):
+        try:
+            registry = self._bindings[name]
+        except KeyError:
+            registry = RegistrationStack(self)
+            self._bindings[name] = registry
+            self._p_changed = 1
+        return registry
+
+    def listRegistrationNames(self):
+        return filter(self._bindings.get,
+                      self._bindings.keys())
+
+    def queryActiveComponent(self, name, default=None):
+        registry = self.queryRegistrations(name)
+        if registry:
+            registration = registry.active()
+            if registration is not None:
+                return registration.getComponent()
+        return default
+
     def getServiceDefinitions(wrapped_self):
         """See IServiceService
         """
@@ -318,7 +342,7 @@
 
 _smattrs = (
     '_modules',                         # PersistentModuleRegistry
-    '_bindings',                        # NameComponentRegistry
+    '_bindings',
 )
 
 class ServiceManagerAdapter(DirectoryAdapter):




More information about the Zope3-Checkins mailing list