[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - ContextDependent.py:1.2 Exceptions.py:1.2 GlobalAdapterService.py:1.2 GlobalFactoryService.py:1.2 GlobalResourceService.py:1.2 GlobalServiceManager.py:1.2 GlobalSkinService.py:1.2 GlobalUtilityService.py:1.2 GlobalViewService.py:1.2 IAdapterService.py:1.2 IContextDependent.py:1.2 IFactory.py:1.2 IFactoryService.py:1.2 IPlacefulComponentArchitecture.py:1.2 IPresentation.py:1.2 IPresentationRequest.py:1.2 IResourceFactory.py:1.2 IResourceService.py:1.2 IServiceManager.py:1.2 IServiceManagerContainer.py:1.2 ISkinService.py:1.2 IToIRegistry.py:1.2 IUtilityService.py:1.2 IView.py:1.2 IViewFactory.py:1.2 IViewService.py:1.2 ServiceManagerContainer.py:1.2 __init__.py:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:29:54 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv20468/lib/python/Zope/ComponentArchitecture

Added Files:
	ContextDependent.py Exceptions.py GlobalAdapterService.py 
	GlobalFactoryService.py GlobalResourceService.py 
	GlobalServiceManager.py GlobalSkinService.py 
	GlobalUtilityService.py GlobalViewService.py 
	IAdapterService.py IContextDependent.py IFactory.py 
	IFactoryService.py IPlacefulComponentArchitecture.py 
	IPresentation.py IPresentationRequest.py IResourceFactory.py 
	IResourceService.py IServiceManager.py 
	IServiceManagerContainer.py ISkinService.py IToIRegistry.py 
	IUtilityService.py IView.py IViewFactory.py IViewService.py 
	ServiceManagerContainer.py __init__.py 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.

=== Zope3/lib/python/Zope/ComponentArchitecture/ContextDependent.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from IContextDependent import IContextDependent
+
+class ContextDependent(object):
+    """standard boilerplate for context dependent objects"""
+
+    __implements__ = IContextDependent
+
+    def __init__(self, context):
+        self.context = context
+


=== Zope3/lib/python/Zope/ComponentArchitecture/Exceptions.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+
+from Zope.Exceptions import NotFoundError
+
+class ComponentLookupError(NotFoundError):
+    "A component could not be found"
+
+class Invalid(Exception):
+    """A component doesn't satisfy a promise
+    """
+
+class Misused(Exception):
+    """A component is being used (registered) for the wrong interface
+    """


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalAdapterService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""adapter service
+"""
+
+from IToIRegistry import IToIRegistry
+from Exceptions import ComponentLookupError
+from IAdapterService import IAdapterService
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+class IGlobalAdapterService(IAdapterService):
+
+    def provideAdapter(forInterface, providedInterface, maker):
+        """Provide an adapter
+
+        An adapter provides an interface for objects that have another
+        interface.
+
+        Arguments:
+
+        forInterface -- The interface the adapter provides an interface for.
+
+        providedInterface -- The provided interface
+
+        maker -- a callable object that gets an adapter component for
+        a context component.
+        """
+
+class GlobalAdapterService:
+    
+    __implements__ = IGlobalAdapterService
+    
+    def __init__(self):
+        self.__adapters = IToIRegistry()
+    
+    def provideAdapter(self, forInterface, providedInterface, maker):
+        """see IGlobalAdapterService interface"""
+        self.__adapters.register(forInterface, providedInterface, maker)
+
+    def getAdapter(self, object, interface):
+        """see IAdapterService interface"""
+        result = self.queryAdapter(object, interface)
+        if result is None:
+            raise ComponentLookupError(object, interface)
+
+        return result
+
+    def queryAdapter(self, object, interface, default=None):
+        """see IAdapterService interface"""
+        clean_object = removeAllProxies(object)
+        if interface.isImplementedBy(clean_object): return object
+        makers = self.__adapters.getForObject(clean_object, interface)
+        if makers is None:
+            return default
+        result = object
+        for maker in makers:
+            result = maker(result)
+        return result
+
+    _clear = __init__
+
+# the global adapter service instance (see component.zcml )
+adapterService = GlobalAdapterService()
+provideAdapter = adapterService.provideAdapter
+
+
+
+_clear = adapterService._clear
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalFactoryService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""factory service
+"""
+
+
+from Interface.Verify import verifyObject
+from IFactory import IFactory
+from IFactoryService import IFactoryService
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+
+class IGlobalFactoryService(IFactoryService):
+
+    def provideFactory(name, factory):
+        """Provide a factory for the given name.
+        """
+
+class GlobalFactoryService:
+    
+    __implements__ = IGlobalFactoryService
+    
+    def __init__(self):
+        self.__factories={}
+
+    def provideFactory(self, name, factory):
+        """See IGlobalFactoryService interface"""
+        verifyObject(IFactory, removeAllProxies(factory))
+        self.__factories[name] = factory
+
+    def createObject(self, name, *args, **kwargs):
+        """See IFactoryService interface"""
+        try: return self.__factories[name](*args, **kwargs)
+        except KeyError:
+            raise ComponentLookupError(name)
+    
+    def getInterfaces(self, name):
+        """See IFactoryService interface"""
+        try: return self.__factories[name].getInterfaces()
+        except KeyError:
+            raise ComponentLookupError(name)
+
+    _clear = __init__
+
+# the global factory service instance (see component.zcml )
+factoryService = GlobalFactoryService()
+
+
+
+
+_clear         = factoryService._clear
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp
\ No newline at end of file


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalResourceService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from IToIRegistry import DataRegistry
+from Exceptions import ComponentLookupError
+from Zope.ComponentArchitecture import getSkin, _marker
+from IResourceService import IResourceService
+
+class IGlobalResourceService(IResourceService):
+
+    def provideResource(name, type, factory, layer='default'):
+        """Provide a resource
+
+        A resource is an inependent component that provides a view
+        type.  It is like a view except that it acts by itself,
+        typically to support views. Common resources include images,
+        style sheets, etc.
+
+        Arguments:
+
+        name -- The resource name
+
+        type -- The resource type, expressed as an interface
+
+        factory -- an IResourceFactory that computes a resource.
+
+        layer -- Optional skin layer. Layers are used to define skins.
+        """
+
+class GlobalResourceService:
+
+    def __init__(self):
+        self.__layers = {}
+
+    __implements__ = IGlobalResourceService
+        
+    # Implementation methods for interface
+    # Zope.ComponentArchitecture.IResourceService.
+
+    def getResource(self, object, name, request):
+        '''See interface IResourceService'''
+
+        resource = self.queryResource(object, name, request)
+
+        if resource is None:
+            raise ComponentLookupError(object, name, type)
+
+        return resource
+
+    def queryResource(self, object, name, request, default=None):
+        '''See interface IResourceService'''
+
+        type = request.getPresentationType()
+        skin = request.getPresentationSkin()
+
+        for layername in getSkin(object, skin, type):
+            layer = self.__layers.get(layername)
+            if not layer: continue
+            reg = layer.get(name, None)
+            if reg is None: continue
+            factory = reg.get(None, type)
+            if factory is None:
+                continue
+
+            return factory(request)
+
+        return default
+        
+        
+    def provideResource(self, name, type, factory, layer='default'):
+        '''See interface IGlobalResourceService'''
+
+        resources = self.__layers.get(layer)
+        if resources is None:
+            resources = self.__layers[layer] = {}
+
+        reg = resources.get(name, None)
+        if reg is None:
+            reg = resources[name] = DataRegistry()
+
+        reg.register(type, factory)
+
+    _clear = __init__
+    
+resourceService = GlobalResourceService()
+provideResource = resourceService.provideResource
+_clear             = resourceService._clear
+
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalServiceManager.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Zope.Exceptions import DuplicationError
+from IServiceManager import IServiceManager
+from Exceptions import ComponentLookupError
+
+
+class IGlobalServiceManager(IServiceManager):
+    
+    def defineService(name, interface):
+        """Define a new service of the given name implementing the given
+        interface.  If the name already exists, raises
+        Zope.Exceptions.DuplicationError"""
+    
+    def provideService(name, component):
+        """provide a service component to do the work of the named
+        service.  If a service component has already been assigned to
+        this name, raise Zope.Exceptions.DuplicationError; if the name
+        has not been defined, raises
+        Zope.ComponentArchitecture.GlobalServiceManager.UndefinedService;
+        if the component does not implement the registered interface for
+        the service name, raises
+        Zope.ComponentArchitecture.GlobalServiceManager.InvalidService.
+        """
+
+class UndefinedService(Exception):
+    """An attempt to register a service that has not been defined
+    """
+
+class InvalidService(Exception):
+    """An attempt to register a service that doesn't implement
+       the required interface
+    """
+    
+class GlobalServiceManager:
+    """service manager"""
+
+    __implements__ = IGlobalServiceManager
+
+    def __init__(self):
+        self.__defs     = {}
+        self.__services = {}
+    
+    def defineService(self, name, interface):
+        """see IGlobalServiceManager interface"""
+
+        if name in self.__defs:
+            raise DuplicationError(name)
+
+        self.__defs[name] = interface
+
+    def getServiceDefinitions(self):
+        """see IServiceManager Interface"""
+        return self.__defs.items()
+
+    def provideService(self, name, component):
+        """see IGlobalServiceManager interface"""
+
+        if name in self.__services:
+            raise DuplicationError(name)
+
+        if name not in self.__defs:
+            raise UndefinedService(name)
+
+        if not self.__defs[name].isImplementedBy(component):
+            raise InvalidService(name, component, self.__defs[name])
+
+        self.__services[name] = component
+
+    def getService(self, name):
+        """see IServiceManager interface"""
+
+        try:
+            return self.__services[name]
+        except KeyError:
+            raise ComponentLookupError(name)
+
+    _clear = __init__
+
+
+serviceManager = GlobalServiceManager() # the global service manager instance
+
+
+
+_clear         = serviceManager._clear
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalSkinService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from IToIRegistry import IToIRegistry
+from Exceptions import ComponentLookupError
+from ISkinService import ISkinService
+from IToIRegistry import DataRegistry
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+
+class IGlobalSkinService(ISkinService):
+
+    def defineSkin(name, view_type, layers):
+        """Define a skin for a given view type as a sequence of layers
+
+        There is a predefined skin, '', with a single layer, ''.
+        """
+
+_default = ('default',)
+
+class GlobalSkinService:
+
+    def __init__(self):
+        self.__skins = {}
+
+    __implements__ = IGlobalSkinService
+        
+    # Implementation methods for interface
+    # Zope.ComponentArchitecture.ISkinService.
+
+    def defineSkin(self, name, view_type, layers):
+        '''See interface IGlobalSkinService'''
+        
+        reg = self.__skins.get(name, None)
+        if reg is None:
+            reg = self.__skins[name] = DataRegistry()
+
+        reg.register(view_type, layers)
+
+    def getSkin(self, object, name, view_type):
+        '''See interface ISkinService'''
+
+        clean_object=removeAllProxies(object)
+        reg = self.__skins.get(name, None)
+        if reg is not None:
+            layers = reg.getForObject(clean_object, view_type)
+            if layers is not None:
+                return layers
+
+        return _default
+
+    _clear = __init__
+    
+skinService = GlobalSkinService()
+
+
+
+_clear     = skinService._clear
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalUtilityService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""utility service
+
+$Id$
+"""
+
+from IUtilityService import IUtilityService
+from IToIRegistry import IRegistry
+from Exceptions import ComponentLookupError
+
+class IGlobalUtilityService(IUtilityService):
+
+    def provideUtility(providedInterface, component):
+        """Provide a utility
+
+        A utility is a component that provides an interface.
+        """
+
+class GlobalUtilityService:
+    
+    __implements__=IGlobalUtilityService
+    
+    def __init__(self):
+        self.__utilities=IRegistry()
+
+    def provideUtility(self, providedInterface, component):
+        """See IGlobalUtilityService interface"""
+        self.__utilities.register(providedInterface, component)
+
+    def getUtility(self, interface, default=None):
+        """See IUtilityService interface"""
+        c = self.queryUtility(interface)
+        if c is None:
+            raise ComponentLookupError(interface)
+        return c
+
+    def queryUtility(self, interface, default=None):
+        """See IUtilityService interface"""
+        c = self.__utilities.get(None, interface)
+        if c is None:
+            c = default
+        return c
+    
+    _clear = __init__
+
+# the global utility service instance (see component.zcml )
+utilityService = GlobalUtilityService()
+
+
+
+
+_clear         = utilityService._clear
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp


=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalViewService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from IToIRegistry import IToIRegistry, IToIDataRegistry
+from Exceptions import ComponentLookupError
+from Zope.ComponentArchitecture import getSkin, _marker
+from IViewService import IViewService
+from Zope.Exceptions import NotFoundError
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+class IGlobalViewService(IViewService):
+    
+    def setDefaultViewName(i_required, i_provided, name):
+        '''Add name to our registry of default view names for
+           the interfaces given.
+        '''
+        
+    def provideView(forInterface, name, type, factory, layer='default'):
+        """Register a view factory
+
+        The factory is a sequence. The last object in the sequence
+        must be an IViewFactory. The other objects in the sequence
+        must be adapter factories.
+        """
+
+class GlobalViewService:
+
+    __implements__ = IGlobalViewService
+
+    def __init__(self):
+        self.__layers = {}
+        self.__default_view_names = IToIDataRegistry()
+
+    def setDefaultViewName(self, i_required, i_provided, name):
+        self.__default_view_names.register(i_required,
+                                           i_provided,
+                                           name)
+        
+    # Implementation methods for interface
+    # Zope.ComponentArchitecture.IViewService.
+
+    def getViewDefinitions(self, name=None, used_for=None, type=None,
+                           layer=None):
+        '''See interface IViewService'''
+
+        result = []
+
+        if layer is None:
+            layers = self.__layers.keys()
+        else:
+            layers = [layer]
+
+        for layername in layers:
+            layer = self.__layers[layername]
+            if name is None:
+                names = layer.keys()
+            else:
+                names = [name]
+
+            for n in names:
+                result.extend(
+                    [{ 'name': n,
+                       'used_for': definition['used_for'],
+                       'type': definition['provides'],
+                       'layer': layername,
+                       'factory': definition['factory'],
+                       }
+                     for definition
+                     in layer[n].getDefinitions(used_for, type)
+                     ]
+                    )
+                    
+        return result                
+
+    def getView(self, object, name, request):
+        '''See interface IViewService'''
+        view = self.queryView(object, name, request)
+        if view is None:
+            raise ComponentLookupError(object, name, type)
+        return view
+
+    def queryView(self, object, name, request, default=None):
+        '''See interface IViewService'''
+
+        type = request.getPresentationType()
+        skin = request.getPresentationSkin()
+
+        clean_object=removeAllProxies(object)
+
+        for layername in getSkin(object, skin, type):
+            layer = self.__layers.get(layername)
+            if not layer:
+                continue
+
+            reg = layer.get(name, None)
+            if reg is None:
+                continue
+
+            makers = reg.getForObject(clean_object, type)
+            if not makers:
+                continue
+
+            result = object
+            for maker in makers[:-1]:
+                result = maker(result)
+
+            return makers[-1](result, request)
+
+        return default
+        
+        
+    def provideView(self, forInterface, name, type, maker, layer='default'):
+        '''See interface IGlobalViewService'''
+
+        views = self.__layers.get(layer)
+        if views is None:
+            views = self.__layers[layer] = {}
+
+        reg = views.get(name, None)
+        if reg is None:
+            reg = views[name] = IToIRegistry()
+
+        reg.register(forInterface, type, maker)
+
+    def getDefaultViewName(self, object, request):
+        '''See interface IViewService'''
+
+        name = self.queryDefaultViewName(object, request)
+
+        if name is None:
+            raise NotFoundError, \
+                  'No default view name found for object %s' % object
+
+        return name
+
+    def queryDefaultViewName(self, object, request, default=None):
+        '''See interface IViewService'''
+
+        type = request.getPresentationType()
+        name = self.__default_view_names.getForObject(object, type)
+
+        if name is None:
+            name = default
+
+        return name
+
+    _clear = __init__
+    
+viewService = GlobalViewService()
+provideView = viewService.provideView
+setDefaultViewName = viewService.setDefaultViewName
+_clear         = viewService._clear
+
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from Zope.Testing.CleanUp import addCleanUp
+addCleanUp(_clear)
+del addCleanUp


=== Zope3/lib/python/Zope/ComponentArchitecture/IAdapterService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IAdapterService(Interface):
+
+    def getAdapter(object, interface):
+        """Look up an adapter that provides an interface for an object
+
+        A Zope.ComponentArchitecture.ComponentLookupError will be
+        raised if the component can't be found.
+        """
+
+    def queryAdapter(object, interface, default=None):
+        """Look up an adapter that provides an interface for an object
+
+        The default will be returned if the component can't be found.
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/IContextDependent.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+from Interface.Attribute import Attribute
+
+class IContextDependent(Interface):
+
+    context = Attribute(
+        """The context of the object
+
+        This is the object being adapted, viewed, extemded, etc.
+        
+        """)


=== Zope3/lib/python/Zope/ComponentArchitecture/IFactory.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""Interface for Factory objects."""
+
+
+from Interface import Interface
+
+class IFactory(Interface):
+
+    def __call__():
+        """Return an instance of the objects we're a factory for."""
+
+
+    def getInterfaces():
+        """Return the interface(s) that objects created by this factory
+        will implement."""


=== Zope3/lib/python/Zope/ComponentArchitecture/IFactoryService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IFactoryService(Interface):
+
+    def createObject(name, *args, **kwargs):
+        """Create a new object using the factory with the given name,
+        passing all remaining arguments to the factory transparently.
+
+        A Zope.ComponentArchitecture.ComponentLookupError will be
+        raised if the factory component can't be found.
+        """
+    def getInterfaces(name):
+        """returns the interface or interface tuple that
+        object instances created by the named factory will implement."""
+    
\ No newline at end of file


=== Zope3/lib/python/Zope/ComponentArchitecture/IPlacefulComponentArchitecture.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+from Interface import Interface
+
+class IPlacefulComponentArchitecture(Interface):
+    """The Component Architecture is defined by six key services,
+    all of which are managed by service managers.
+    """
+
+    # basic service manager tools
+    
+    def getServiceManager(context):
+        """returns the nearest service manager to the context; if the
+        context is None the global service manager is always returned"""
+
+    def getService(context, name):
+        """returns the service defined by 'name' nearest to the context;
+        if the context is None the pertinent global service is always
+        returned"""
+
+    def getServiceDefinitions(context): 
+        """returns a dictionary of the service definitions pertinent to
+        the given context, in the format {nameString: serviceInterface}.
+        If the context is None the global definitions will be returned.
+        The default behavior of placeful service managers is to include
+        service definitions above them, but this can be overridden"""
+
+    # placeful service convenience tools
+
+    def getNextServiceManager(context):
+        """Given a placefully wrapped service manager, service, or
+        service component, will return the next placeful service manager
+        (wrapped) above the current service manager, or the global
+        service manager if none is higher.  if the context is the global
+        service manager, the function raises
+        Zope.ComponentArchitecture.ComponentLookupError."""
+
+    def getNextService(context, name):
+        """Identical to getNextServiceManager, but will try to find the
+        next named service, proceeding finally to the global versions,
+        and then returning 
+        Zope.ComponentArchitecture.ComponentLookupError"""
+
+    # Utility service
+
+    def getUtility(context, interface):
+        """Get the utility that provides interface
+
+        Returns the nearest utility to the context that implements
+        the specified interface.  If one is not found, raises
+        Zope.ComponentArchitecture.ComponentLookupError."""
+
+    def querytUtility(context, interface, default=None):
+        """Look for the utility that provides interface
+
+        Returns the nearest utility to the context that implements
+        the specified interface.  If one is not found, returns default."""
+
+    # Adapter service
+
+    def getAdapter(object, interface, default=None, context=None):
+        """Get adapter to interface for object
+
+        Returns the nearest adapter to the context that can adapt
+        object to interface.  If context is not specified, attempts to
+        use wrapping around object to specify a context.  If a matching
+        adapter cannot be found, raises
+        Zope.ComponentArchitecture.ComponentLookupError."""
+
+    def queryAdapter(object, interface, default=None, context=None):
+        """Look for adapter to interface for object
+
+        Returns the nearest adapter to the context that can adapt
+        object to interface.  If context is not specified, attempts to
+        use wrapping around object to specify a context.  If a matching
+        adapter cannot be found, returns default."""
+
+    # Factory service
+
+    def createObject(context, name, *args, **kwargs):
+        """finds the factory of the given name that is nearest to the
+        context, and passes the other given arguments to the factory
+        to create a new instance. Returns a reference to the new
+        object.  If a matching factory cannot be found raises
+        Zope.ComponentArchitecture.ComponentLookupError"""
+
+    def getFactoryInterfaces(context, name):
+        """finds the factory of the given name that is nearest to the
+        context, and returns the interface or interface tuple that
+        object instances created by the named factory will implement."""
+
+    # Skin service
+
+    def getSkin(wrapped_object, name, view_type):
+        """returns the nearest skin (sequence of layer names) to the
+        object, as specified by the name and the view type (browser,
+        xml-rpc, etc.) as expressed by an interface.  If a matching skin
+        is not found, raises
+        Zope.ComponentArchitecture.ComponentLookupError
+        
+        There is a predefined skin in the global skin service, '', with
+        a single layer, ''."""
+
+    # View service
+
+    def getView(wrapped_object, name, request):
+        """Get a named view for a given object.
+
+        The request must implement IPresentationRequest: it provides
+        the view type and the skin name.  The nearest one to the
+        object is found. If a matching view cannot be found, raises
+        Zope.ComponentArchitecture.ComponentLookupError.
+        
+        """
+
+    def queryView(wrapped_object, name, request, default=None):
+        """Look for a named view for a given object.
+
+        The request must implement IPresentationRequest: it provides the view
+        type and the skin name.  The nearest one to the object is
+        found. If a matching view cannot be found, returns default.
+
+        """
+
+    def getDefaultViewName(wrapped_object, request):
+        """Get the name of the default view for the object and request.
+
+        The request must implement IPresentationRequest, and provides the
+        desired view type.  The nearest one to the object is found.
+        If a matching default view name cannot be found, raises
+        Zope.NotFoundError.
+        
+        """
+
+    def queryDefaultViewName(wrapped_object, request, default=None):
+        """Look for the name of the default view for the object and request.
+        
+        The request must implement IPresentationRequest, and provides the
+        desired view type.  The nearest one to the object is found.
+        If a matching default view name cannot be found, returns the
+        default.
+        
+        """
+
+    def getViewDefinitions(context, name=None, used_for=None, \
+                           view_type=None, layer=None):
+        """Get matching view definitions for the given context.  If the
+        context is None then it will explicitly use the global view
+        service.
+
+        Get view definitions as a sequence of mapping objects with keys:
+
+        - name
+
+        - used_for
+
+        - type
+
+        - layer
+
+        - factory
+
+        The arguments may be given as keyword arguments and define a
+        query for the retrieval.
+        """
+
+    # Resource service
+
+    def getResource(wrapped_object, name, request):
+        """Get a named resource for a given request
+
+        The request must implement IPresentationRequest.
+
+        The object provides a place to look for placeful resources.
+        
+        A Zope.ComponentArchitecture.ComponentLookupError will be
+        raised if the component can't be found.
+        """
+
+    def queryResource(wrapped_object, name, request, default=None):
+        """Get a named resource for a given request
+
+        The request must implement IPresentationRequest.
+
+        The object provides a place to look for placeful resources.
+        
+        If the component can't be found, the default is returned.
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/IPresentation.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+from Interface.Attribute import Attribute
+
+class IPresentation(Interface):
+    """Presentation components provide interfaces to external actors
+
+    The are created for requests, which encapsulate external actors,
+    connections, etc.
+
+    """
+
+    request = Attribute(
+        """The request
+
+        The request is a surrogate for the user. It also provides the
+        presentation type and skin. It is of type
+        IPresentationRequest.
+
+        """)


=== Zope3/lib/python/Zope/ComponentArchitecture/IPresentationRequest.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IPresentationRequest(Interface):
+    """An IPresentationRequest provides methods for getting view meta data.
+    """
+
+    def getPresentationType():
+        """Get a view type
+
+        The view type is expressed as an interface, as would be passed
+        to IViewService.getView.
+        """
+
+    def getPresentationSkin():
+        """Get the skin to be used for a request.
+
+        The skin is a string as would be passed
+        to IViewService.getView.
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/IResourceFactory.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IResourceFactory(Interface):
+
+    def __call__(request):
+        """Create a resource for a request
+
+        The request must be an IPresentationRequest.
+
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/IResourceService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IResourceService(Interface):
+
+    def getResource(object, name, request):
+        """Look up a named resource for a given request
+
+        The request must implement IPresentationRequest.
+
+        The object provides a place to look for placeful resources.
+
+        A Zope.ComponentArchitecture.ComponentLookupError will be
+        raised if the component can't be found.
+        """
+
+    def queryResource(object, name, request, default=None):
+        """Look up a named resource for a given request
+
+        The request must implement IPresentationRequest.
+
+        The object provides a place to look for placeful resources.
+
+        The default will be returned if the component can't be found.
+        """
+
+
+
+
+
+


=== Zope3/lib/python/Zope/ComponentArchitecture/IServiceManager.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IServiceManager(Interface):
+
+    def getServiceDefinitions():
+        """Retrieve all Service Definitions
+
+        Should return a list of tuples (name, interface)
+        """        
+
+    def getService(name):
+        """Retrieve a service implementation
+
+        Raises ComponentLookupError if the service can't be found.
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/IServiceManagerContainer.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IReadServiceManagerContainer(Interface):
+
+    def getServiceManager(default=None):
+        """Returns the service manager contained in this object.
+
+        If there isn't a service manager, we return the default or
+        raise a component lookup error if no default was provided.
+        """
+
+    def hasServiceManager():
+        """Query to find out if the component defines a service manager."""
+
+class IWriteServiceManagerContainer(Interface):
+
+    def setServiceManager(sm):
+        """Sets the service manager for this object."""
+
+class IServiceManagerContainer(IReadServiceManagerContainer,
+                               IWriteServiceManagerContainer):
+    pass
+


=== Zope3/lib/python/Zope/ComponentArchitecture/ISkinService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class ISkinService(Interface):
+
+    def getSkin(object, name, view_type):
+        """Return the sequence of layers (names) making up the skin.
+
+        The object provides a place to look for placeful skin definitions.
+
+        If the skin was not defined, an empty sequence will be returned.
+        """
\ No newline at end of file


=== Zope3/lib/python/Zope/ComponentArchitecture/IToIRegistry.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+Registry of components that are registered as requiring
+an interface and providing an interface.
+"""
+
+from Interface import Interface
+from Interface.Implements import objectImplements
+from Exceptions import Invalid
+from types import ListType, TupleType
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+class IToIRegistry:  # Interface to Interface
+    
+    def __init__(self):
+        self._reg = {}
+        
+    def _registerAll(self, require, primary_provide, c, provide):
+        '''
+        Registers a component using (require, provide) as a key.
+        Also registers superinterfaces of the provided interface,
+        stopping when the registry already has a component
+        that provides a more general interface or when the Base is Interface.
+        '''
+        reg = self._reg
+        reg[(require, provide)] = (primary_provide, c)
+        bases = getattr(provide, '__bases__', ())
+        for base in bases:
+            if base is Interface:
+                # Never register the say-nothing Interface.
+                continue
+            existing = reg.get((require, base), None)
+            if existing is not None:
+                existing_provide = existing[0]
+                if existing_provide is not primary_provide:
+                    if not existing_provide.extends(primary_provide):
+                        continue
+                    # else we are registering a general component
+                    # after a more specific component.
+            self._registerAll(require, primary_provide, c, base)
+
+
+    def register(self, require, provide, maker,
+            ArrayTypes=(ListType, TupleType)):
+        '''
+        Registers a component.
+        '''
+        if not isinstance(maker, ArrayTypes):
+            maker = [maker]
+        if not maker == filter(callable, maker):
+            raise TypeError("The registered component callable is not "
+                            "callable")
+        
+        self._registerAll(require, provide, maker, provide)
+
+
+    def _find(self, require, provide):
+        return self._reg.get((require, provide), None)
+
+    def get(self, ob_interface, provide):
+        """
+        Finds a registered component that provides the given interface.
+        Returns None if not found.
+        """
+        c = self._find(ob_interface, provide)
+        if c is not None:
+            return c[1]
+        bases = getattr(ob_interface, '__bases__', ())
+        if bases:
+            # 'require' might be a subinterface of a required interface
+            # for a registered component.
+            for base in bases:
+                c = self.get(base, provide)
+                if c is not None:
+                    return c
+        return None
+
+
+    def getDefinitions(self, used_for=None, provide=None):
+        if used_for is not None:
+            if provide is not None:
+                c = self._find(used_for, provide)
+                if c is None:
+                    return []
+                else:
+                    return [{ 'used_for': used_for,
+                              'provides': provide,
+                              'factory': c
+                              }]
+            else:
+                return self.getDefinitionsFor(used_for)
+                
+        # get everything
+        reg = self._reg
+        return [{ 'used_for': key[0],
+                  'provides': key[1],
+                  'factory': reg[key][1],
+                  } for key in reg]
+
+    def getDefinitionsFor(self, used_for):
+        """Return the components registered to provide some interfaces
+        """
+        # This is tricky, because we want the most specific provider
+        seen = {}
+        reg = self._reg
+        for for_, provides in reg:
+            if not used_for.extends(for_, 0):
+                continue
+            if provides not in seen or for_.extends(seen[provides]):
+                seen[provides] = for_
+
+        return [{ 'used_for': seen[provides],
+                  'provides': provides,
+                  'factory': reg[seen[provides], provides][1],
+                  } for provides in seen]
+
+    def getAll(self, ob_interface, provide, result=None, seen=None):
+        """Get all components that match an interface
+        
+        Finds all registered components that provides the given interface.
+        Returns None if not found.
+        """
+        if result is None:
+            result = []
+        if seen is None:
+            seen = {}
+
+        if ob_interface in seen:
+            return result
+        
+        c = self._find(ob_interface, provide)
+        if c is not None:
+            result.append(c[1])
+        seen[ob_interface] = 1
+
+        bases = getattr(ob_interface, '__bases__', ())
+        if bases:
+            # 'require' might be a subinterface of a required interface
+            # for a registered component.
+            for base in bases:
+                self.getAll(base, provide, result, seen)
+
+        return result
+
+    def getForObject(self, ob, provided):
+        for i in objectImplements(removeAllProxies(ob)):
+            c=self.get(i, provided)
+            if c is not None: return c
+        return self.get(None, provided)
+
+    def getAllForObject(self, ob, provided):
+        """Get all components that match an object's interfaces
+        
+        Finds all registered components that provides the given interface.
+        Returns None if not found.
+        """
+        result = []
+        seen = {}
+        for i in objectImplements(removeAllProxies(ob)):
+            self.getAll(i, provided, result, seen)
+
+        return self.getAll(None, provided, result, seen)
+    
+
+class IRegistry(IToIRegistry):
+    """Registry for components that provide an interface but down require one
+
+    For example, this is used for registering utilities and resources.
+    """
+
+    def register(self, provide, c):
+        '''
+        Registers a component.
+        '''
+        if not provide.isImplementedBy(c):
+            raise Invalid("The registered component doesn't implement "
+                              "the promised interface.")
+        
+        self._registerAll(None, provide, c, provide)
+
+class DataRegistry(IToIRegistry):
+    """XXX need doc for this"""
+
+    def register(self, provide, c):
+        '''
+        Registers data for an interface.
+        '''
+        self._registerAll(None, provide, c, provide)
+
+class IToIDataRegistry(IToIRegistry):
+    """Store data accociated with two interfaces
+
+    This is used for default view names, which are registered for
+    specific presentation types and object types.
+    """
+
+    def register(self, require, provide, data):
+        '''
+        Registers data for combination of a require and a
+        provide interface.
+        '''
+        self._registerAll(require, provide, data, provide)
+
+class TypeRegistry(IToIRegistry):
+    """Register data for objects of a given type.
+
+    Type is expressed by an interface.
+
+    For example, this allows us to register subscription lists by event types.
+    """
+
+    def register(self, require, data):
+        '''
+        Registers data for combination of a require and a
+        provide interface.
+        '''
+        self._registerAll(require, None, data, None)
+
+    def getForObject(self, ob):
+        return IToIRegistry.getForObject(self, removeAllProxies(ob), None)
+
+    def getAllForObject(self, ob):
+        return IToIRegistry.getAllForObject(self, removeAllProxies(ob), None)
+
+    def getForType(self, interface):
+        return self.get(interface, None)
+
+    def getJustForType(self, interface):
+        """Return the data for the type without falling back to base types
+        """
+        r = self._find(interface, None)
+        return r and r[1]


=== Zope3/lib/python/Zope/ComponentArchitecture/IUtilityService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IUtilityService(Interface):
+
+    def getUtility(interface):
+        """Look up a utility that provides interface.
+
+        If one is not found, raises
+        Zope.ComponentArchitecture.ComponentLookupError."""
+
+    def getUtility(interface, default=None):
+        """Look up a utility that provides an interface.
+
+        If one is not found, returns default."""
+


=== Zope3/lib/python/Zope/ComponentArchitecture/IView.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from IContextDependent import IContextDependent
+from IPresentation import IPresentation
+
+class IView(IPresentation, IContextDependent):
+    """Views provide a connection between an external actor and an object
+    """


=== Zope3/lib/python/Zope/ComponentArchitecture/IViewFactory.py 1.1 => 1.2 ===
+#
+# Copyright (c) 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IViewFactory(Interface):
+
+    def __call__(object, request):
+        """Create a view for the object and request
+
+        The request must be an IPresentationRequest.
+
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/IViewService.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Interface import Interface
+
+class IViewService(Interface):
+
+    def getView(object, name, request):
+        """Get a named view for a given object and request
+
+        The request must implement IPresentationRequest.
+
+        The object also provides a place to look for placeful views.
+
+        A Zope.ComponentArchitecture.ComponentLookupError will be
+        raised if the component can't be found.
+        """
+
+    def queryView(object, name, request, default=None):
+        """Look for a named view for a given object and request
+
+        The request must implement IPresentationRequest.
+
+        The object also provides a place to look for placeful views.
+
+        The default will be returned
+        if the component can't be found.
+        """
+
+    def getDefaultViewName(object, request):
+        """Get the name of the default view for the object and request
+        
+        The request must implement IPresentationRequest.
+
+        A Zope.NotFoundError will be raised if the suitable
+        default view name for the object cannot be found.
+        """
+
+    def queryDefaultViewName(object, request, default=None):
+        """Look for the name of the default view for the object and request
+        
+        The request must implement IPresentationRequest.
+
+        The default will be returned if a suitable
+        default view name for the object cannot be found.
+        """
+
+    def getViewDefinitions(name=None, use_for=None, type=None, layer=None):
+        """Get matching view definitions
+
+        Get view definitions as a sequence of mapping objects with keys:
+
+        - name
+
+        - used_for
+
+        - type
+
+        - layer
+
+        - factory
+
+        The arguments may be given as keyword arguments and define a
+        query for the retrieval.
+        """


=== Zope3/lib/python/Zope/ComponentArchitecture/ServiceManagerContainer.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+
+from IServiceManagerContainer import IServiceManagerContainer
+from IServiceManager import IServiceManager
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+
+_marker = object()
+
+class ServiceManagerContainer:
+
+    __implements__ =  IServiceManagerContainer
+
+    ############################################################
+    # Implementation methods for interface
+    # Zope.ComponentArchitecture.IServiceManagerContainer.
+
+    def hasServiceManager(self):
+        '''See interface IReadServiceManagerContainer'''
+        return hasattr(self, '_ServiceManagerContainer__sm')
+
+    def getServiceManager(self, default=_marker):
+        '''See interface IReadServiceManagerContainer'''
+
+        try:
+            return self.__sm # no name
+        except AttributeError:
+            if default is _marker:
+                raise ComponentLookupError
+            else:
+                return default
+
+    def setServiceManager(self, sm):
+        '''See interface IWriteServiceManagerContainer'''
+
+        if IServiceManager.isImplementedBy(sm):
+            self.__sm = sm
+        else:
+            raise ValueError('setServiceManager requires an IServiceManager')
+
+    #
+    ############################################################
+


=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.1 => 1.2 ===
+#
+# 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.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from IPlacefulComponentArchitecture import IPlacefulComponentArchitecture
+from Exceptions import ComponentLookupError
+from GlobalServiceManager import serviceManager
+__implements__ = IPlacefulComponentArchitecture
+
+from Zope.Proxy.ContextWrapper import getWrapperContainer
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+
+
+_marker = object() # this exact marker is used throughout CA
+
+# placeful component architecture functions
+
+# basic service manager tools
+
+def getServiceManager(context): # hookable
+    return getServiceManager_hook(context)
+
+def getServiceManager_hook(context): # default hook
+    return serviceManager
+
+def getService(context, name):
+    return getServiceManager(context).getService(name)
+
+def getServiceDefinitions(context): 
+    return getServiceManager(context).getServiceDefinitions()
+
+# placeful service manager convenience tools
+
+def getNextServiceManager(context): # hookable
+    return getNextServiceManager_hook(context)
+
+def getNextServiceManager_hook(context): #default hook
+    raise ComponentLookupError
+    
+def getNextService(context, name):
+    sm=getNextServiceManager(context)
+    if sm is not None:
+        return sm.getService(name)
+    return None
+
+
+# Utility service
+
+def getUtility(context, interface):
+    return getService(context, 'Utilities').getUtility(interface)
+
+def queryUtility(context, interface, default=None):
+    return getService(context, 'Utilities').queryUtility(interface, default)
+
+# Adapter service
+
+def getAdapter(object, interface, context=None):
+    if context is None:
+        context = object
+    return getService(context, 'Adapters').getAdapter(
+        object, interface)
+
+def queryAdapter(object, interface, default=_marker, context=None):
+    if context is None:
+        context = object
+    return getService(context, 'Adapters').queryAdapter(
+        object, interface, default)
+
+# Factory service
+
+def createObject(context, name, *args, **kwargs):
+    return getService(context, 'Factories').createObject(name, *args, **kwargs)
+
+def getFactoryInterfaces(context, name):
+    return getService(context, 'Factories').getInterfaces(name)
+
+# Skin service
+
+def getSkin(wrapped_object, name, view_type):
+    return getService(wrapped_object, 
+                      'Skins').getSkin(wrapped_object, name, view_type)
+
+# View service
+
+def getView(wrapped_object, name, request):
+    return getService(wrapped_object, 
+                      'Views').getView(wrapped_object, name, request)
+
+def queryView(wrapped_object, name, request, default=None):
+    return getService(wrapped_object, 
+                      'Views').queryView(wrapped_object, name,
+                                         request, default)
+
+def getDefaultViewName(wrapped_object, request):
+    return getService(wrapped_object, 
+                      'Views').getDefaultViewName(wrapped_object,
+                                                  request)
+
+def queryDefaultViewName(wrapped_object, request, default=None):
+    return getService(wrapped_object,
+                      'Views').queryDefaultViewName(wrapped_object,
+                                                    request, default)
+
+def getViewDefinitions(context, name=None, used_for=None, 
+                       view_type=None, layer=None):
+    return getService(context, 'Views').getViewDefinitions(context,
+                                                           name, used_for,
+                                                           view_type, layer)
+
+# Resource service
+
+def getResource(wrapped_object, name, request):
+    return getService(wrapped_object,
+                      'Resources').getResource(
+        wrapped_object, name, request)
+
+def queryResource(wrapped_object, name, request, default=None):
+    return getService(wrapped_object,
+                      'Resources').queryResource(
+        wrapped_object, name, request, default)
+
+
+#def _clear():
+#    from Service import _clear;     _clear()
+#    from ViewService import _clear; _clear()
+#    from ResourceService import _clear; _clear()
+#    from SkinService import _clear; _clear()