[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/ Redeprecated a number of things that didn't generate warnings

Jim Fulton jim at zope.com
Sun Mar 12 16:46:55 EST 2006


Log message for revision 65931:
  Redeprecated a number of things that didn't generate warnings
  before. Sigh. Also fixed all the depecation warnings generated by
  running the zope.component tests.
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/component/__init__.py
  A   Zope3/branches/jim-adapter/src/zope/component/adapter.py
  A   Zope3/branches/jim-adapter/src/zope/component/back35.py
  U   Zope3/branches/jim-adapter/src/zope/component/bbb/__init__.py
  D   Zope3/branches/jim-adapter/src/zope/component/bbb/adapter.py
  D   Zope3/branches/jim-adapter/src/zope/component/bbb/contextdependent.py
  D   Zope3/branches/jim-adapter/src/zope/component/bbb/exceptions.py
  D   Zope3/branches/jim-adapter/src/zope/component/bbb/service.py
  D   Zope3/branches/jim-adapter/src/zope/component/bbb/servicenames.py
  D   Zope3/branches/jim-adapter/src/zope/component/bbb/utility.py
  A   Zope3/branches/jim-adapter/src/zope/component/contextdependent.py
  A   Zope3/branches/jim-adapter/src/zope/component/exceptions.py
  U   Zope3/branches/jim-adapter/src/zope/component/factory.txt
  U   Zope3/branches/jim-adapter/src/zope/component/interfaces.py
  U   Zope3/branches/jim-adapter/src/zope/component/registry.py
  A   Zope3/branches/jim-adapter/src/zope/component/service.py
  A   Zope3/branches/jim-adapter/src/zope/component/servicenames.py
  U   Zope3/branches/jim-adapter/src/zope/component/site.py
  U   Zope3/branches/jim-adapter/src/zope/component/socketexample.txt
  U   Zope3/branches/jim-adapter/src/zope/component/tests.py
  A   Zope3/branches/jim-adapter/src/zope/component/utility.py
  U   Zope3/branches/jim-adapter/src/zope/security/checker.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/component/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/__init__.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/__init__.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -24,43 +24,33 @@
 from zope.component.interfaces import IComponentRegistrationConvenience
 from zope.component.interfaces import IDefaultViewName
 from zope.component.interfaces import IFactory
-from zope.component.interfaces import ISiteManager
 from zope.component.interfaces import ComponentLookupError
+from zope.component.interfaces import IComponentLookup
 from zope.component.globalregistry import base as globalSiteManager
 
+import zope.deferredimport
+
 _class_types = type, ClassType
 
-##############################################################################
-# BBB: Import some backward-compatibility; 12/10/2004
-from zope.component.bbb import exceptions
-sys.modules['zope.component.exceptions'] = exceptions
-from zope.component.bbb import service
-sys.modules['zope.component.service'] = service
-from zope.component.bbb import adapter
-sys.modules['zope.component.adapter'] = adapter
-from zope.component.bbb import utility
-sys.modules['zope.component.utility'] = utility
-from zope.component.bbb import servicenames
-sys.modules['zope.component.servicenames'] = servicenames
-from zope.component.bbb import contextdependent
-sys.modules['zope.component.contextdependent'] = contextdependent
 
-service.__warn__ = False
-service.serviceManager = service.GlobalServiceManager(
-    'serviceManager', __name__, globalSiteManager)
-service.__warn__ = True
+zope.deferredimport.deprecated(
+    "Use IComponentLookup instead.  ISiteManager will be removed in Zope 3.5.",
+    ISiteManager = "zope.component.interfaces:IComponentLookup",
+    )
 
-from zope.component.bbb import getGlobalServices, getGlobalService
-from zope.component.bbb import getServices, getService
-from zope.component.bbb import getServiceDefinitions
-from zope.component.bbb import getView, queryView
-from zope.component.bbb import getMultiView, queryMultiView
-from zope.component.bbb import getViewProviding, queryViewProviding
-from zope.component.bbb import getDefaultViewName, queryDefaultViewName
-from zope.component.bbb import getResource, queryResource
-##############################################################################
+zope.deferredimport.deprecatedFrom(
+    "Deprecated and will go away in Zope 3.5",
+    'zope.component.back35',
+    'getGlobalServices', 'getGlobalService',
+    'getServices', 'getService',
+    'getServiceDefinitions',
+    'getView', 'queryView',
+    'getMultiView', 'queryMultiView',
+    'getViewProviding', 'queryViewProviding',
+    'getDefaultViewName', 'queryDefaultViewName',
+    'getResource', 'queryResource',
+    )
 
-
 # Try to be hookable. Do so in a try/except to avoid a hard dependency.
 try:
     from zope.hookable import hookable
@@ -80,10 +70,10 @@
     if context is None:
         return getGlobalSiteManager()
     else:
-        # Use the global site manager to adapt context to `ISiteManager`
+        # Use the global site manager to adapt context to `IComponentLookup`
         # to avoid the recursion implied by using a local `getAdapter()` call.
         try:
-            return ISiteManager(context)
+            return IComponentLookup(context)
         except TypeError, error:
             raise ComponentLookupError(*error.args)
 
@@ -290,7 +280,7 @@
         else:
             raise TypeError("Missing 'provides' argument")
 
-    getGlobalSiteManager().provideUtility(provides, component, name)
+    getGlobalSiteManager().registerUtility(component, provides, name)
 
 
 def provideAdapter(factory, adapts=None, provides=None, name=''):
@@ -307,7 +297,7 @@
         except AttributeError:
             raise TypeError("Missing 'adapts' argument")
 
-    getGlobalSiteManager().provideAdapter(adapts, provides, name, factory)
+    getGlobalSiteManager().registerAdapter(factory, adapts, provides, name)
 
 def provideSubscriptionAdapter(factory, adapts=None, provides=None):
     if provides is None:
@@ -323,7 +313,8 @@
         except AttributeError:
             raise TypeError("Missing 'adapts' argument")
 
-    getGlobalSiteManager().subscribe(adapts, provides, factory)
+    getGlobalSiteManager().registerSubscriptionAdapter(
+        factory, adapts, provides)
 
 def provideHandler(factory, adapts=None):
 
@@ -333,4 +324,4 @@
         except AttributeError:
             raise TypeError("Missing 'adapts' argument")
 
-    getGlobalSiteManager().subscribe(adapts, None, factory)
+    getGlobalSiteManager().registerHandler(factory, adapts)

Copied: Zope3/branches/jim-adapter/src/zope/component/adapter.py (from rev 65920, Zope3/branches/jim-adapter/src/zope/component/bbb/adapter.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/adapter.py	2006-03-12 17:52:22 UTC (rev 65920)
+++ Zope3/branches/jim-adapter/src/zope/component/adapter.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,169 @@
+##############################################################################
+#
+# 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.1 (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.
+#
+##############################################################################
+
+
+import warnings
+
+warnings.warn("This module is deprecated and will go away in Zope 3.5. ",
+              DeprecationWarning, 2)
+
+
+import sys
+import warnings
+from types import ClassType
+
+from zope.component.interfaces import IRegistry, ComponentLookupError
+from zope.component.bbb.interfaces import IAdapterService
+from zope.component.bbb.service import GlobalService
+from zope.component.registry import AdapterRegistration, SubscriptionRegistration
+from zope.interface import implements, providedBy, Interface, implementedBy
+from zope.interface.interfaces import IInterface
+
+class IGlobalAdapterService(IAdapterService, IRegistry):
+
+    def register(required, provided, name, factory, info=''):
+        """Register an adapter factory
+
+        :Parameters:
+          - `required`: a sequence of specifications for objects to be
+             adapted.
+          - `provided`: The interface provided by the adapter
+          - `name`: The adapter name
+          - `factory`: The object used to compute the adapter
+          - `info`: Provide some info about this particular adapter.
+        """
+
+    def subscribe(required, provided, factory, info=''):
+        """Register a subscriber factory
+
+        :Parameters:
+          - `required`: a sequence of specifications for objects to be
+             adapted.
+          - `provided`: The interface provided by the adapter
+          - `name`: The adapter name
+          - `factory`: The object used to compute the subscriber
+          - `info`: Provide some info about this particular adapter.
+        """
+
+class AdapterService(object):
+    """Base implementation of an adapter service, implementing only the
+    `IAdapterService` interface.
+
+    No write-methods were implemented.
+    """
+
+    implements(IAdapterService)
+
+    def __init__(self, sitemanager=None):
+        if sitemanager is None:
+            from zope.component.globalregistry import BaseGlobalComponents
+            sitemanager = BaseGlobalComponents()
+        self.sm = sitemanager
+
+    def __getattr__(self, name):
+        attr = getattr(self.sm.adapters, name)
+        if attr is not None:
+            return attr
+        raise AttributeError(name)
+
+
+class GlobalAdapterService(AdapterService, GlobalService):
+    """Global Adapter Service implementation."""
+
+    implements(IGlobalAdapterService)
+
+    def __init__(self, sitemanager=None):
+        super(GlobalAdapterService, self).__init__(sitemanager)
+
+    def register(self, required, provided, name, factory, info=''):
+        """Register an adapter
+
+        >>> registry = GlobalAdapterService()
+        >>> class R1(Interface):
+        ...     pass
+        >>> class R2(R1):
+        ...     pass
+        >>> class P1(Interface):
+        ...     pass
+        >>> class P2(P1):
+        ...     pass
+
+        >>> registry.register((R1, ), P2, 'bob', 'c1', 'd1')
+        >>> registry.register((R1, ), P2,    '', 'c2', 'd2')
+        >>> registry.lookup((R2, ), P1, '')
+        'c2'
+
+        >>> registrations = map(repr, registry.registrations())
+        >>> registrations.sort()
+        >>> for registration in registrations:
+        ...    print registration
+        AdapterRegistration(('R1',), 'P2', '', 'c2', 'd2')
+        AdapterRegistration(('R1',), 'P2', 'bob', 'c1', 'd1')
+
+        Let's make sure that we can also register regular classes for
+        adaptation.
+
+        >>> class O1(object):
+        ...     pass
+        >>> class O2(object):
+        ...     pass
+        >>> class O3(object):
+        ...     def __init__(self, obj1, obj2=None):
+        ...         pass
+
+        >>> registry.register((O1, ), R1, '', O3)
+        >>> registry.queryAdapter(O1(), R1, '').__class__
+        <class 'zope.component.bbb.adapter.O3'>
+
+        >>> registry.register((O1, O2), R1, '', O3)
+        >>> registry.queryMultiAdapter((O1(), O2()), R1, '').__class__
+        <class 'zope.component.bbb.adapter.O3'>
+        """
+        self.sm.provideAdapter(required, provided, name, factory, info)
+
+    def subscribe(self, required, provided, factory, info=''):
+        """Register an subscriptions adapter
+
+        >>> registry = GlobalAdapterService()
+        >>> class R1(Interface):
+        ...     pass
+        >>> class R2(R1):
+        ...     pass
+        >>> class P1(Interface):
+        ...     pass
+        >>> class P2(P1):
+        ...     pass
+
+        >>> registry.subscribe((R1, ), P2, 'c1', 'd1')
+        >>> registry.subscribe((R1, ), P2, 'c2', 'd2')
+        >>> subscriptions = map(str, registry.subscriptions((R2, ), P1))
+        >>> subscriptions.sort()
+        >>> subscriptions
+        ['c1', 'c2']
+
+        >>> registrations = map(repr, registry.registrations())
+        >>> registrations.sort()
+        >>> for registration in registrations:
+        ...    print registration
+        SubscriptionRegistration(('R1',), 'P2', 'c1', 'd1')
+        SubscriptionRegistration(('R1',), 'P2', 'c2', 'd2')
+
+        """
+        self.sm.subscribe(required, provided, factory, info)
+
+    def registrations(self):
+        for registration in self.sm.registrations():
+            if isinstance(registration,
+                          (AdapterRegistration, SubscriptionRegistration)):
+                yield registration

Added: Zope3/branches/jim-adapter/src/zope/component/back35.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/back35.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/back35.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,133 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Features that will be deprecated in Zope 3.5
+
+$Id$
+"""
+import sys
+import warnings
+
+from zope.interface import Interface, providedBy
+from zope.component.bbb.interfaces import IServiceService, IDefaultViewName
+from zope.component.service import GlobalServiceManager
+
+# Try to be hookable. Do so in a try/except to avoid a hard dependency.
+from zope.hookable import hookable
+
+def getGlobalServices():
+    from zope.component import getGlobalSiteManager
+    return GlobalServiceManager('servicemanager', 'zope.component.service',
+                                getGlobalSiteManager())
+
+def getGlobalService(name):
+    return getGlobalServices().getService(name)
+
+def getServices(context=None):
+    if context is None:
+        return getGlobalServices()
+    else:
+        # Use the global service manager to adapt context to IServiceService
+        # to avoid the recursion implied by using a local getAdapter call.
+        try:
+            return IServiceService(context)
+        except TypeError, error:
+            from zope.component.bbb.exceptions import ComponentLookupError
+            raise ComponentLookupError(*error.args)
+
+getServices = hookable(getServices)
+
+def getService(name, context=None):
+    return getServices(context).getService(name)
+
+def getServiceDefinitions(context=None):
+    return getServices(context).getServiceDefinitions()
+
+# Presentation API
+
+def getView(object, name, request, providing=Interface, context=None):
+    view = queryView(object, name, request, context=context,
+                     providing=providing)
+    if view is not None:
+        return view
+
+    from zope.component.bbb.exceptions import ComponentLookupError
+    raise ComponentLookupError("Couldn't find view",
+                               name, object, context, request, providing)
+
+def queryView(object, name, request,
+              default=None, providing=Interface, context=None):
+    from zope.component import queryMultiAdapter
+    return queryMultiAdapter((object, request), providing, name,
+                             default, context)
+
+queryView = hookable(queryView)
+
+def getMultiView(objects, request, providing=Interface, name='', context=None):
+    view = queryMultiView(objects, request, providing, name, context=context)
+    if view is not None:
+        return view
+
+    from zope.component.bbb.exceptions import ComponentLookupError
+    raise ComponentLookupError("Couldn't find view",
+                               name, objects, context, request)
+
+def queryMultiView(objects, request, providing=Interface, name='',
+                   default=None, context=None):
+    from zope.component import queryMultiAdapter
+    return queryMultiAdapter(objects+(request,), providing, name,
+                             default, context)
+
+def getViewProviding(object, providing, request, context=None):
+    return getView(object, '', request, providing, context)
+
+def queryViewProviding(object, providing, request, default=None, 
+                       context=None):
+    return queryView(object, '', request, default, providing, context)
+
+def getDefaultViewName(object, request, context=None):
+    view = queryDefaultViewName(object, request, context=context)
+    if view is not None:
+        return view
+
+    from zope.component.bbb.exceptions import ComponentLookupError
+    raise ComponentLookupError("Couldn't find default view name",
+                               context, request)
+
+def queryDefaultViewName(object, request, default=None, context=None):
+    from zope.component.bbb.exceptions import ComponentLookupError
+    from zope.component import getSiteManager
+    try:
+        adapters = getSiteManager(context)
+    except ComponentLookupError:
+        # Oh blast, no adapter service. We're probably just running from a test
+        return default
+
+    name = adapters.adapters.lookup(map(providedBy, (object, request)),
+                                    IDefaultViewName)
+    if name is not None:
+        return name
+    return default
+
+def getResource(name, request, providing=Interface, context=None):
+    view = queryResource(name, request, providing=providing, context=context)
+    if view is not None:
+        return view
+
+    from zope.component.bbb.exceptions import ComponentLookupError
+    raise ComponentLookupError("Couldn't find resource", name, request)
+
+def queryResource(name, request, default=None, providing=Interface,
+                  context=None):
+    from zope.component import queryAdapter
+    return queryAdapter(request, providing, name, default, context)


Property changes on: Zope3/branches/jim-adapter/src/zope/component/back35.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: Zope3/branches/jim-adapter/src/zope/component/bbb/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/__init__.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/__init__.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -17,218 +17,4 @@
 """
 __docformat__ = "reStructuredText"
 
-__warn__ = True
 
-import sys
-import warnings
-
-from zope.interface import Interface, providedBy
-from zope.component.bbb.interfaces import IServiceService, IDefaultViewName
-from zope.component.bbb.service import GlobalServiceManager
-
-# Try to be hookable. Do so in a try/except to avoid a hard dependency.
-try:
-    from zope.hookable import hookable
-except ImportError:
-    def hookable(ob):
-        return ob
-
-def warningLevel():
-    """Returns the number of the first stack frame outside of zope.component"""
-    try:
-        level = 2
-        while sys._getframe(level).f_globals['__name__']=='zope.component.bbb':
-            level += 1
-        return level
-    except ValueError:
-        return 2
-
-
-def getGlobalServices():
-    if __warn__:
-        warnings.warn(
-            "The concept of services has been deprecated. You probably want to "
-            "use `getGlobalSiteManager()`.",
-            DeprecationWarning, warningLevel())
-    from zope.component import getGlobalSiteManager
-    return GlobalServiceManager('servicemanager', 'zope.component.service',
-                                getGlobalSiteManager())
-
-def getGlobalService(name):
-    if __warn__:
-        warnings.warn(
-            "The concept of services has been deprecated. You probably want to "
-            "use `getGlobalSiteManager()` or `getUtility()`.",
-            DeprecationWarning, warningLevel())
-    return getGlobalServices().getService(name)
-
-def getServices(context=None):
-    if __warn__:
-        warnings.warn(
-            "The concept of services has been deprecated. You probably want to "
-            "use `getGlobalSiteManager()` or `getUtility()`.",
-            DeprecationWarning, warningLevel())
-    if context is None:
-        return getGlobalServices()
-    else:
-        # Use the global service manager to adapt context to IServiceService
-        # to avoid the recursion implied by using a local getAdapter call.
-        try:
-            return IServiceService(context)
-        except TypeError, error:
-            from zope.component.bbb.exceptions import ComponentLookupError
-            raise ComponentLookupError(*error.args)
-
-getServices = hookable(getServices)
-
-def getService(name, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concept of services has been deprecated. You probably want to "
-            "use `getGlobalSiteManager()` or `getUtility()`.",
-            DeprecationWarning, warningLevel())
-    return getServices(context).getService(name)
-
-def getServiceDefinitions(context=None):
-    if __warn__:
-        warnings.warn(
-            "The concept of services has been deprecated.",
-            DeprecationWarning, warningLevel())
-    return getServices(context).getServiceDefinitions()
-
-# Presentation API
-
-def getView(object, name, request, providing=Interface, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `getMultiAdapter((object, request), providing, name, "
-            "context)`.",
-            DeprecationWarning, warningLevel())
-    view = queryView(object, name, request, context=context,
-                     providing=providing)
-    if view is not None:
-        return view
-
-    from zope.component.bbb.exceptions import ComponentLookupError
-    raise ComponentLookupError("Couldn't find view",
-                               name, object, context, request, providing)
-
-def queryView(object, name, request,
-              default=None, providing=Interface, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `queryMultiAdapter((object, request), providing, name, "
-            "default, context)`.",
-            DeprecationWarning, warningLevel())
-    from zope.component import queryMultiAdapter
-    return queryMultiAdapter((object, request), providing, name,
-                             default, context)
-
-queryView = hookable(queryView)
-
-def getMultiView(objects, request, providing=Interface, name='', context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `getMultiAdapter(objects+(request,), providing, name, "
-            "context)`.",
-            DeprecationWarning, warningLevel())
-    view = queryMultiView(objects, request, providing, name, context=context)
-    if view is not None:
-        return view
-
-    from zope.component.bbb.exceptions import ComponentLookupError
-    raise ComponentLookupError("Couldn't find view",
-                               name, objects, context, request)
-
-def queryMultiView(objects, request, providing=Interface, name='',
-                   default=None, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `getMultiAdapter(objects+(request,), providing, name, "
-            "default, context)`.",
-            DeprecationWarning, warningLevel())
-    from zope.component import queryMultiAdapter
-    return queryMultiAdapter(objects+(request,), providing, name,
-                             default, context)
-
-def getViewProviding(object, providing, request, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `getMultiAdapter((object, request), providing, name, "
-            "context)`.",
-            DeprecationWarning, warningLevel())
-    return getView(object, '', request, providing, context)
-
-def queryViewProviding(object, providing, request, default=None, 
-                       context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `queryMultiAdapter((object, request), providing, name, "
-            "default, context)`.",
-            DeprecationWarning, warningLevel())
-    return queryView(object, '', request, default, providing, context)
-
-def getDefaultViewName(object, request, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `zapi.getDefaultViewName()` instead.",
-            DeprecationWarning, warningLevel())
-    view = queryDefaultViewName(object, request, context=context)
-    if view is not None:
-        return view
-
-    from zope.component.bbb.exceptions import ComponentLookupError
-    raise ComponentLookupError("Couldn't find default view name",
-                               context, request)
-
-def queryDefaultViewName(object, request, default=None, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a view has been deprecated. You want to "
-            "use `zapi.queryDefaultViewName()` instead.",
-            DeprecationWarning, warningLevel())
-    from zope.component.bbb.exceptions import ComponentLookupError
-    from zope.component import getSiteManager
-    try:
-        adapters = getSiteManager(context)
-    except ComponentLookupError:
-        # Oh blast, no adapter service. We're probably just running from a test
-        return default
-
-    name = adapters.adapters.lookup(map(providedBy, (object, request)),
-                                    IDefaultViewName)
-    if name is not None:
-        return name
-    return default
-
-def getResource(name, request, providing=Interface, context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a resource has been deprecated. You want "
-            "to use `getAdapter(request, providing, name, context)`",
-            DeprecationWarning, warningLevel())
-    view = queryResource(name, request, providing=providing, context=context)
-    if view is not None:
-        return view
-
-    from zope.component.bbb.exceptions import ComponentLookupError
-    raise ComponentLookupError("Couldn't find resource", name, request)
-
-def queryResource(name, request, default=None, providing=Interface,
-                  context=None):
-    if __warn__:
-        warnings.warn(
-            "The concrete concept of a resource has been deprecated. You want "
-            "to use `queryAdapter(request, providing, name, default, context)`",
-            DeprecationWarning, warningLevel())
-    from zope.component import queryAdapter
-    return queryAdapter(request, providing, name, default, context)
-
-

Deleted: Zope3/branches/jim-adapter/src/zope/component/bbb/adapter.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/adapter.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/adapter.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -1,167 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-"""Global Adapter Service
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import sys
-import warnings
-from types import ClassType
-
-from zope.component.interfaces import IRegistry, ComponentLookupError
-from zope.component.bbb.interfaces import IAdapterService
-from zope.component.bbb.service import GlobalService
-from zope.component.registry import AdapterRegistration, SubscriptionRegistration
-from zope.interface import implements, providedBy, Interface, implementedBy
-from zope.interface.interfaces import IInterface
-
-class IGlobalAdapterService(IAdapterService, IRegistry):
-
-    def register(required, provided, name, factory, info=''):
-        """Register an adapter factory
-
-        :Parameters:
-          - `required`: a sequence of specifications for objects to be
-             adapted.
-          - `provided`: The interface provided by the adapter
-          - `name`: The adapter name
-          - `factory`: The object used to compute the adapter
-          - `info`: Provide some info about this particular adapter.
-        """
-
-    def subscribe(required, provided, factory, info=''):
-        """Register a subscriber factory
-
-        :Parameters:
-          - `required`: a sequence of specifications for objects to be
-             adapted.
-          - `provided`: The interface provided by the adapter
-          - `name`: The adapter name
-          - `factory`: The object used to compute the subscriber
-          - `info`: Provide some info about this particular adapter.
-        """
-
-class AdapterService(object):
-    """Base implementation of an adapter service, implementing only the
-    `IAdapterService` interface.
-
-    No write-methods were implemented.
-    """
-
-    implements(IAdapterService)
-
-    def __init__(self, sitemanager=None):
-        if sitemanager is None:
-            from zope.component.globalregistry import BaseGlobalComponents
-            sitemanager = BaseGlobalComponents()
-        self.sm = sitemanager
-
-    def __getattr__(self, name):
-        attr = getattr(self.sm.adapters, name)
-        if attr is not None:
-            return attr
-        raise AttributeError(name)
-
-
-class GlobalAdapterService(AdapterService, GlobalService):
-    """Global Adapter Service implementation."""
-
-    implements(IGlobalAdapterService)
-
-    def __init__(self, sitemanager=None):
-        super(GlobalAdapterService, self).__init__(sitemanager)
-
-    def register(self, required, provided, name, factory, info=''):
-        """Register an adapter
-
-        >>> registry = GlobalAdapterService()
-        >>> class R1(Interface):
-        ...     pass
-        >>> class R2(R1):
-        ...     pass
-        >>> class P1(Interface):
-        ...     pass
-        >>> class P2(P1):
-        ...     pass
-
-        >>> registry.register((R1, ), P2, 'bob', 'c1', 'd1')
-        >>> registry.register((R1, ), P2,    '', 'c2', 'd2')
-        >>> registry.lookup((R2, ), P1, '')
-        'c2'
-
-        >>> registrations = map(repr, registry.registrations())
-        >>> registrations.sort()
-        >>> for registration in registrations:
-        ...    print registration
-        AdapterRegistration(('R1',), 'P2', '', 'c2', 'd2')
-        AdapterRegistration(('R1',), 'P2', 'bob', 'c1', 'd1')
-
-        Let's make sure that we can also register regular classes for
-        adaptation.
-
-        >>> class O1(object):
-        ...     pass
-        >>> class O2(object):
-        ...     pass
-        >>> class O3(object):
-        ...     def __init__(self, obj1, obj2=None):
-        ...         pass
-
-        >>> registry.register((O1, ), R1, '', O3)
-        >>> registry.queryAdapter(O1(), R1, '').__class__
-        <class 'zope.component.bbb.adapter.O3'>
-
-        >>> registry.register((O1, O2), R1, '', O3)
-        >>> registry.queryMultiAdapter((O1(), O2()), R1, '').__class__
-        <class 'zope.component.bbb.adapter.O3'>
-        """
-        self.sm.provideAdapter(required, provided, name, factory, info)
-
-    def subscribe(self, required, provided, factory, info=''):
-        """Register an subscriptions adapter
-
-        >>> registry = GlobalAdapterService()
-        >>> class R1(Interface):
-        ...     pass
-        >>> class R2(R1):
-        ...     pass
-        >>> class P1(Interface):
-        ...     pass
-        >>> class P2(P1):
-        ...     pass
-
-        >>> registry.subscribe((R1, ), P2, 'c1', 'd1')
-        >>> registry.subscribe((R1, ), P2, 'c2', 'd2')
-        >>> subscriptions = map(str, registry.subscriptions((R2, ), P1))
-        >>> subscriptions.sort()
-        >>> subscriptions
-        ['c1', 'c2']
-
-        >>> registrations = map(repr, registry.registrations())
-        >>> registrations.sort()
-        >>> for registration in registrations:
-        ...    print registration
-        SubscriptionRegistration(('R1',), 'P2', 'c1', 'd1')
-        SubscriptionRegistration(('R1',), 'P2', 'c2', 'd2')
-
-        """
-        self.sm.subscribe(required, provided, factory, info)
-
-    def registrations(self):
-        for registration in self.sm.registrations():
-            if isinstance(registration,
-                          (AdapterRegistration, SubscriptionRegistration)):
-                yield registration

Deleted: Zope3/branches/jim-adapter/src/zope/component/bbb/contextdependent.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/contextdependent.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/contextdependent.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -1,27 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-"""A simple mix-in class that implements IContextDependent. 
-
-$Id$
-"""
-from zope.component.interfaces import IContextDependent
-from zope.interface import implements
-
-class ContextDependent(object):
-    """standard boilerplate for context dependent objects"""
-
-    implements(IContextDependent)
-
-    def __init__(self, context):
-        self.context = context

Deleted: Zope3/branches/jim-adapter/src/zope/component/bbb/exceptions.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/exceptions.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/exceptions.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -1,24 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-"""Exceptions used by the Component Architecture
-
-$Id$
-"""
-from zope.component.interfaces import ComponentLookupError
-from zope.component.interfaces import Invalid, Misused
-
-
-__all__ = ["ComponentLookupError",
-           "Invalid",
-           "Misused"]

Deleted: Zope3/branches/jim-adapter/src/zope/component/bbb/service.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/service.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/service.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -1,170 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-"""Service Manager implementation
-
-$Id$
-"""
-__warn__ = True
-import warnings
-
-from zope.exceptions import DuplicationError
-from zope.component.bbb.interfaces import IServiceService
-from zope.interface import implements, Interface, directlyProvides
-
-
-class IGlobalServiceManager(IServiceService):
-
-    def defineService(name, interface):
-        """Define a new service of the given name implementing the given
-        interface.  If the name already exists, raises
-        DuplicationError"""
-
-    def provideService(name, component):
-        """Register a service 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 DuplicationError; if the name has not been
-        defined, raises UndefinedService; if the component does not
-        implement the registered interface for the service name,
-        raises InvalidService.
-
-        """
-
-class IService(Interface):
-    """Marker interface that is used as utility interface to simulate
-       services."""
-
-class IServiceDefinition(Interface):
-    """Marker interface that is used as utility interface to store service
-    defintions (name, interface)."""
-
-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(object):
-    """service manager"""
-
-    implements(IGlobalServiceManager)
-
-    def __init__(self, name=None, module=None, sitemanager=None):
-        if __warn__:
-            warnings.warn(
-                "The concept of services has been deprecated. You now have "
-                "only adapters and utilities, which are managed by the site "
-                "manager, which is probably the object you want.",
-                DeprecationWarning, 2)
-        if sitemanager is None:
-            from zope.component.globalregistry import BaseGlobalComponents
-            sitemanager = BaseGlobalComponents()
-        self.sm = sitemanager
-        self.__name__ = name
-        self.__module__ = module
-
-    def _clear(self):
-        pass
-
-    def __reduce__(self):
-        # Global service managers are pickled as global objects
-        return self.__name__
-
-    def defineService(self, name, interface):
-        """see IGlobalServiceManager interface"""
-
-        utils = self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition)
-        names = [n for n, iface in utils]
-        if name in names:
-            raise DuplicationError(name)
-
-        self.sm.provideUtility(IServiceDefinition, (name, interface),
-                                name=name, strict=False)
-
-    def getServiceDefinitions(self):
-        """see IServiceService Interface"""
-        defs = list(self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition))
-        return defs + [('Services', IServiceService)]
-
-    def provideService(self, name, component, force=False):
-        """see IGlobalServiceManager interface, above
-
-        The force keyword allows one to replace an existing
-        service.  This is mostly useful in testing scenarios.
-        """
-
-        if not force and self.sm.queryUtility(IService, name) is not None:
-            raise DuplicationError(name)
-
-        utils = self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition)
-        if name not in [name for name, iface in utils]:
-            raise UndefinedService(name)
-
-        if not dict(self.getServiceDefinitions())[name].providedBy(component):
-            raise InvalidService(name, component,
-                                 dict(self.getServiceDefinitions())[name])
-
-        if isinstance(component, GlobalService):
-            component.__parent__ = self
-            component.__name__ = name
-
-        # Ignore the base services, since their functionality is provided by
-        # the SM.
-        if name in ('Adapters', 'Utilities', 'Services'):
-            return
-
-        directlyProvides(component, IService)
-        self.sm.provideUtility(IService, component, name)
-
-    def getService(self, name):
-        """see IServiceService interface"""
-        if name == 'Services':
-            return self
-
-        if name == 'Adapters':
-            from zope.component.bbb.adapter import GlobalAdapterService
-            return GlobalAdapterService(self.sm)
-
-        if name == 'Utilities':
-            from zope.component.bbb.utility import GlobalUtilityService
-            return GlobalUtilityService(self.sm)
-
-        service = self.sm.queryUtility(IService, name)
-        if service is None:
-            from zope.component.bbb.exceptions import ComponentLookupError
-            raise ComponentLookupError(name)
-
-        return service
-
-
-def GS(service_manager, service_name):
-    return service_manager.getService(service_name)
-
-class GlobalService(object):
-
-    def __reduce__(self):
-        return GS, (self.__parent__, self.__name__)
-
-
-def __getSM(sitemanager=None):
-    return GlobalServiceManager('serviceManager', __name__, sitemanager)
-
-def defineService(name, interface, sitemanager=None):
-    if sitemanager is None:
-        from zope.component.globalregistry import base
-    __getSM(base).defineService(name, interface)

Deleted: Zope3/branches/jim-adapter/src/zope/component/bbb/servicenames.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/servicenames.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/servicenames.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -1,20 +0,0 @@
-##############################################################################
-#
-# 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.1 (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.
-#
-##############################################################################
-"""Default service names for CA core services
-
-$Id$
-"""
-Adapters = 'Adapters'
-Utilities = 'Utilities'
-Services = 'Services'

Deleted: Zope3/branches/jim-adapter/src/zope/component/bbb/utility.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/utility.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/bbb/utility.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# 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.1 (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 zope.component.interfaces import Invalid, ComponentLookupError, IRegistry
-from zope.component.bbb.interfaces import IUtilityService
-from zope.component.service import GlobalService, IService, IServiceDefinition
-from zope.component.registry import UtilityRegistration
-import zope.interface
-
-class IGlobalUtilityService(IUtilityService, IRegistry):
-
-    def provideUtility(providedInterface, component, name='', info=''):
-        """Provide a utility
-
-        A utility is a component that provides an interface.
-        """
-
-class UtilityService(object):
-    """Provide IUtilityService
-
-    Mixin that superimposes utility management on adapter registery
-    implementation
-    """
-
-    def __init__(self, sitemanager=None):
-        self.__parent__ = None
-        if sitemanager is None:
-            from zope.component.site import GlobalSiteManager
-            sitemanager = GlobalSiteManager()
-        self.sm = sitemanager
-
-    def __getattr__(self, name):
-        attr = getattr(self.sm, name)
-        if attr is not None:
-            return attr
-
-        attr = getattr(self.sm.utilities, name)
-        if attr is not None:
-            return attr
-
-        raise AttributeError(name)
-
-
-class GlobalUtilityService(UtilityService, GlobalService):
-
-    zope.interface.implementsOnly(IGlobalUtilityService)
-
-    def __init__(self, sitemanager=None):
-        super(GlobalUtilityService, self).__init__(sitemanager)
-
-    def provideUtility(self, providedInterface, component, name='', info=''):
-        self.sm.provideUtility(providedInterface, component, name, info)
-
-    def registrations(self):
-        for reg in self.sm.registrations():
-            if isinstance(reg, UtilityRegistration):
-                if not reg.provided in (IService, IServiceDefinition): 
-                    yield reg

Copied: Zope3/branches/jim-adapter/src/zope/component/contextdependent.py (from rev 65919, Zope3/branches/jim-adapter/src/zope/component/bbb/contextdependent.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/contextdependent.py	2006-03-12 14:20:53 UTC (rev 65919)
+++ Zope3/branches/jim-adapter/src/zope/component/contextdependent.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,29 @@
+##############################################################################
+#
+# 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.1 (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.
+#
+##############################################################################
+
+import warnings
+
+warnings.warn("This module is deprecated and will go away in Zope 3.5.",
+              DeprecationWarning, 2)
+
+from zope.component.interfaces import IContextDependent
+from zope.interface import implements
+
+class ContextDependent(object):
+    """standard boilerplate for context dependent objects"""
+
+    implements(IContextDependent)
+
+    def __init__(self, context):
+        self.context = context

Copied: Zope3/branches/jim-adapter/src/zope/component/exceptions.py (from rev 65919, Zope3/branches/jim-adapter/src/zope/component/bbb/exceptions.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/exceptions.py	2006-03-12 14:20:53 UTC (rev 65919)
+++ Zope3/branches/jim-adapter/src/zope/component/exceptions.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# 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.1 (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$
+"""
+
+import warnings
+
+warnings.warn("This module is deprecated and will go away in Zope 3.5. "
+              "Use zope.component.interfaces instead.",
+              DeprecationWarning, 2)
+
+from zope.component.interfaces import ComponentLookupError
+from zope.component.interfaces import Invalid, Misused
+
+
+__all__ = ["ComponentLookupError",
+           "Invalid",
+           "Misused"]

Modified: Zope3/branches/jim-adapter/src/zope/component/factory.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/factory.txt	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/factory.txt	2006-03-12 21:46:54 UTC (rev 65931)
@@ -101,7 +101,7 @@
   >>> gsm = zope.component.getGlobalSiteManager() 
 
   >>> from zope.component.interfaces import IFactory
-  >>> gsm.provideUtility(IFactory, factory, 'klass')
+  >>> gsm.registerUtility(factory, IFactory, 'klass')
 
 Creating an Object
 ++++++++++++++++++

Modified: Zope3/branches/jim-adapter/src/zope/component/interfaces.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/interfaces.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/interfaces.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -23,12 +23,7 @@
 # BBB: Backward-compatibility; 12/05/2004
 from bbb.interfaces import *
 
-# BBB: Can be removed in 3.3
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-class ComponentLookupError(NotFoundError):
+class ComponentLookupError(LookupError):
     """A component could not be found."""
 
 class Invalid(Exception):

Modified: Zope3/branches/jim-adapter/src/zope/component/registry.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/registry.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/registry.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -24,6 +24,8 @@
 
 class Components(object):
 
+    interface.implements(interfaces.IComponents)
+
     def __init__(self, bases=()):
         self._init_registries()
         self._init_registrations()

Copied: Zope3/branches/jim-adapter/src/zope/component/service.py (from rev 65919, Zope3/branches/jim-adapter/src/zope/component/bbb/service.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/service.py	2006-03-12 14:20:53 UTC (rev 65919)
+++ Zope3/branches/jim-adapter/src/zope/component/service.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,175 @@
+##############################################################################
+#
+# 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.1 (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.
+#
+##############################################################################
+import warnings
+
+warnings.warn("This module is deprecated and will go away in Zope 3.5.",
+              DeprecationWarning, 2)
+
+import zope.component
+from zope.exceptions import DuplicationError
+from zope.component.bbb.interfaces import IServiceService
+from zope.interface import implements, Interface, directlyProvides
+
+
+class IGlobalServiceManager(IServiceService):
+
+    def defineService(name, interface):
+        """Define a new service of the given name implementing the given
+        interface.  If the name already exists, raises
+        DuplicationError"""
+
+    def provideService(name, component):
+        """Register a service 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 DuplicationError; if the name has not been
+        defined, raises UndefinedService; if the component does not
+        implement the registered interface for the service name,
+        raises InvalidService.
+
+        """
+
+class IService(Interface):
+    """Marker interface that is used as utility interface to simulate
+       services."""
+
+class IServiceDefinition(Interface):
+    """Marker interface that is used as utility interface to store service
+    defintions (name, interface)."""
+
+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
+    """
+
+__warn__ = True
+class GlobalServiceManager(object):
+    """service manager"""
+
+    implements(IGlobalServiceManager)
+
+    def __init__(self, name=None, module=None, sitemanager=None):
+        if __warn__:
+            warnings.warn(
+                "The concept of services has been deprecated. You now have "
+                "only adapters and utilities, which are managed by the site "
+                "manager, which is probably the object you want.",
+                DeprecationWarning, 2)
+        if sitemanager is None:
+            from zope.component.globalregistry import BaseGlobalComponents
+            sitemanager = BaseGlobalComponents()
+        self.sm = sitemanager
+        self.__name__ = name
+        self.__module__ = module
+
+    def _clear(self):
+        pass
+
+    def __reduce__(self):
+        # Global service managers are pickled as global objects
+        return self.__name__
+
+    def defineService(self, name, interface):
+        """see IGlobalServiceManager interface"""
+
+        utils = self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition)
+        names = [n for n, iface in utils]
+        if name in names:
+            raise DuplicationError(name)
+
+        self.sm.provideUtility(IServiceDefinition, (name, interface),
+                                name=name, strict=False)
+
+    def getServiceDefinitions(self):
+        """see IServiceService Interface"""
+        defs = list(self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition))
+        return defs + [('Services', IServiceService)]
+
+    def provideService(self, name, component, force=False):
+        """see IGlobalServiceManager interface, above
+
+        The force keyword allows one to replace an existing
+        service.  This is mostly useful in testing scenarios.
+        """
+
+        if not force and self.sm.queryUtility(IService, name) is not None:
+            raise DuplicationError(name)
+
+        utils = self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition)
+        if name not in [name for name, iface in utils]:
+            raise UndefinedService(name)
+
+        if not dict(self.getServiceDefinitions())[name].providedBy(component):
+            raise InvalidService(name, component,
+                                 dict(self.getServiceDefinitions())[name])
+
+        if isinstance(component, GlobalService):
+            component.__parent__ = self
+            component.__name__ = name
+
+        # Ignore the base services, since their functionality is provided by
+        # the SM.
+        if name in ('Adapters', 'Utilities', 'Services'):
+            return
+
+        directlyProvides(component, IService)
+        self.sm.provideUtility(IService, component, name)
+
+    def getService(self, name):
+        """see IServiceService interface"""
+        if name == 'Services':
+            return self
+
+        if name == 'Adapters':
+            from zope.component.bbb.adapter import GlobalAdapterService
+            return GlobalAdapterService(self.sm)
+
+        if name == 'Utilities':
+            from zope.component.bbb.utility import GlobalUtilityService
+            return GlobalUtilityService(self.sm)
+
+        service = self.sm.queryUtility(IService, name)
+        if service is None:
+            from zope.component.bbb.exceptions import ComponentLookupError
+            raise ComponentLookupError(name)
+
+        return service
+
+
+def GS(service_manager, service_name):
+    return service_manager.getService(service_name)
+
+class GlobalService(object):
+
+    def __reduce__(self):
+        return GS, (self.__parent__, self.__name__)
+
+
+def __getSM(sitemanager=None):
+    return GlobalServiceManager('serviceManager', __name__, sitemanager)
+
+def defineService(name, interface, sitemanager=None):
+    if sitemanager is None:
+        from zope.component.globalregistry import base
+    __getSM(base).defineService(name, interface)
+
+
+__warn__ = False
+serviceManager = GlobalServiceManager('serviceManager', __name__)
+__warn__ = True

Copied: Zope3/branches/jim-adapter/src/zope/component/servicenames.py (from rev 65919, Zope3/branches/jim-adapter/src/zope/component/bbb/servicenames.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/servicenames.py	2006-03-12 14:20:53 UTC (rev 65919)
+++ Zope3/branches/jim-adapter/src/zope/component/servicenames.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# 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.1 (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.
+#
+##############################################################################
+
+import warnings
+
+warnings.warn("This module is deprecated and will go away in Zope 3.5.",
+              DeprecationWarning, 2)
+
+Adapters = 'Adapters'
+Utilities = 'Utilities'
+Services = 'Services'

Modified: Zope3/branches/jim-adapter/src/zope/component/site.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/site.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/site.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -24,7 +24,7 @@
 warnings.warn("The zope.component.site module has been deprecated and "
               "will be removed.  Most of the functionality now resides "
               "in the zope.component.globalregistry module.",
-              DeprecationWarning, stacklevel=1)
+              DeprecationWarning, stacklevel=2)
 
 from zope.component.registry import Components as SiteManager
 from zope.component.registry import AdapterRegistration

Modified: Zope3/branches/jim-adapter/src/zope/component/socketexample.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/socketexample.txt	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/socketexample.txt	2006-03-12 21:46:54 UTC (rev 65931)
@@ -83,9 +83,7 @@
 
   >>> import zope.component
   >>> gsm = zope.component.getGlobalSiteManager()
-  
-  >>> gsm.provideAdapter((IGermanSocket,), IUSSocket, '',
-  ...                    GermanToUSSocketAdapter)
+  >>> gsm.registerAdapter(GermanToUSSocketAdapter, (IGermanSocket,), IUSSocket)
 
 `zope.component` is the component architecture API that is being
 presented by this file. You registered an adapter from `IGermanSocket`
@@ -162,10 +160,10 @@
 Now, we need a way to keep the two adapters apart. Thus we register them with
 a name:
 
-  >>> gsm.provideAdapter((IGermanSocket,), IUSSocket, 'shaver',
-  ...                    GermanToUSSocketAdapter)
-  >>> gsm.provideAdapter((IGermanSocket,), IUSSocket, 'dvd',
-  ...                    GermanToUSSocketAdapterAndTransformer)
+  >>> gsm.registerAdapter(GermanToUSSocketAdapter,
+  ...                     (IGermanSocket,), IUSSocket, 'shaver',)
+  >>> gsm.registerAdapter(GermanToUSSocketAdapterAndTransformer,
+  ...                     (IGermanSocket,), IUSSocket, 'dvd')
 
 Now we simply look up the adapters using their labels (called *name*):
 
@@ -239,8 +237,8 @@
 You now register the combination, so that you know you can create a
 `IUSGroundedSocket`:
 
-  >>> gsm.provideAdapter((IGermanSocket, IGrounder), IUSGroundedSocket, 'mp3',
-  ...                    GroundedGermanToUSSocketAdapter)
+  >>> gsm.registerAdapter(GroundedGermanToUSSocketAdapter,
+  ...                 (IGermanSocket, IGrounder), IUSGroundedSocket, 'mp3')
 
 Given the grounder
 
@@ -318,15 +316,17 @@
 
   >>> class PowderExtinguisher(FireExtinguisher):
   ...     pass
-  >>> gsm.subscribe((IFire,), IFireExtinguisher, PowderExtinguisher)
+  >>> gsm.registerSubscriptionAdapter(PowderExtinguisher, 
+  ...                                 (IFire,), IFireExtinguisher)
 
   >>> class Blanket(FireExtinguisher):
   ...     pass
-  >>> gsm.subscribe((IFire,), IFireExtinguisher, Blanket)
+  >>> gsm.registerSubscriptionAdapter(Blanket, (IFire,), IFireExtinguisher)
 
   >>> class SprinklerSystem(FireExtinguisher):
   ...     pass
-  >>> gsm.subscribe((IFire,), IFireExtinguisher, SprinklerSystem)
+  >>> gsm.registerSubscriptionAdapter(SprinklerSystem,
+  ...                                 (IFire,), IFireExtinguisher)
 
 Now let use all these things to put out the fire:
 
@@ -378,7 +378,7 @@
 Like for adapters, we now have to add the newly-acquired generator to our
 inventory by registering it as a utility:
 
-  >>> gsm.provideUtility(IUSSocket, generator)
+  >>> gsm.registerUtility(generator, IUSSocket)
 
 We can now get the utility using
 
@@ -430,7 +430,7 @@
 
 Once it arrives, we add it to our inventory:
 
-  >>> gsm.provideUtility(IUSSocket, panel, 'Solar Panel')
+  >>> gsm.registerUtility(panel, IUSSocket, 'Solar Panel')
 
 You can now access the solar panel using
 
@@ -501,7 +501,7 @@
 implemented interface from the class. We now register the factory:
 
   >>> from zope.component.interfaces import IFactory
-  >>> gsm.provideUtility(IFactory, factory, 'SolarPanel')
+  >>> gsm.registerUtility(factory, IFactory, 'SolarPanel')
 
 We can now get a list of interfaces the produced object will provide:
 
@@ -528,7 +528,7 @@
 
 Once you register several factories
 
-  >>> gsm.provideUtility(IFactory, Factory(Generator), 'Generator')
+  >>> gsm.registerUtility(Factory(Generator), IFactory, 'Generator')
 
 you can also determine, which available factories will create objects
 providing a certian interface:
@@ -555,22 +555,22 @@
 
   >>> gsm = zope.component.getGlobalSiteManager()
 
-  >>> from zope.component.site import globalSiteManager
+  >>> from zope.component import globalSiteManager
   >>> gsm is globalSiteManager
   True
-  >>> from zope.component.interfaces import ISiteManager
-  >>> ISiteManager.providedBy(gsm)
+  >>> from zope.component.interfaces import IComponentLookup
+  >>> IComponentLookup.providedBy(gsm)
   True
-  >>> from zope.component.site import IGlobalSiteManager
-  >>> IGlobalSiteManager.providedBy(gsm)
+  >>> from zope.component.interfaces import IComponents
+  >>> IComponents.providedBy(gsm)
   True
 
 You can also lookup at site manager in a given context. The only requirement
 is that the context can be adapted to a site manager. So let's create a
 special site manager:
 
-  >>> from zope.component.site import SiteManager
-  >>> sm = SiteManager()
+  >>> from zope.component.globalregistry import BaseGlobalComponents
+  >>> sm = BaseGlobalComponents()
 
 Now we create a context that adapts to the site manager via the `__conform__`
 method as specied in PEP 246.
@@ -579,7 +579,7 @@
   ...     def __init__(self, sm):
   ...         self.sm = sm
   ...     def __conform__(self, interface):
-  ...         if interface.isOrExtends(ISiteManager):
+  ...         if interface.isOrExtends(IComponentLookup):
   ...             return self.sm
 
 We now instantiate the `Context` with our special site manager:

Modified: Zope3/branches/jim-adapter/src/zope/component/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/tests.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/component/tests.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -23,7 +23,7 @@
 
 from zope.component.interfaces import ComponentLookupError
 from zope.component.interfaces import IComponentArchitecture
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import IComponentLookup
 from zope.component.testing import setUp, tearDown
 
 class I1(interface.Interface):
@@ -134,16 +134,16 @@
         self.context = context
 
 
-class ConformsToISiteManager(object):
-    """This object allows the sitemanager to conform/adapt to `ISiteManager`
-    and thus to itself."""
+class ConformsToIComponentLookup(object):
+    """This object allows the sitemanager to conform/adapt to
+    `IComponentLookup` and thus to itself."""
 
     def __init__(self, sitemanager):
         self.sitemanager = sitemanager
 
     def __conform__(self, interface):
         """This method is specified by the adapter PEP to do the adaptation."""
-        if interface is ISiteManager:
+        if interface is IComponentLookup:
             return self.sitemanager
 
 
@@ -158,7 +158,8 @@
 def test_getGlobalSiteManager():
     """One of the most important functions is to get the global site manager.
 
-      >>> from zope.component.site import IGlobalSiteManager, globalSiteManager
+      >>> from zope.component.interfaces import IComponentLookup
+      >>> from zope.component.globalregistry import base
 
     Get the global site manager via the CA API function:
 
@@ -167,9 +168,9 @@
     Make sure that the global site manager implements the correct interface
     and is the global site manager instance we expect to get.
 
-      >>> IGlobalSiteManager.providedBy(gsm)
+      >>> IComponentLookup.providedBy(gsm)
       True
-      >>> globalSiteManager is gsm
+      >>> base is gsm
       True
 
     Finally, ensure that we always get the same global site manager, otherwise
@@ -184,9 +185,9 @@
     manager instance.
 
     We don't know anything about the default service manager, except that it
-    is an `ISiteManager`.
+    is an `IComponentLookup`.
 
-      >>> ISiteManager.providedBy(component.getSiteManager())
+      >>> IComponentLookup.providedBy(component.getSiteManager())
       True
 
     Calling `getSiteManager()` with no args is equivalent to calling it with a
@@ -195,9 +196,10 @@
       >>> component.getSiteManager() is component.getSiteManager(None)
       True
 
-    If the context passed to `getSiteManager()` is not `None`, it is adapted
-    to `ISiteManager` and this adapter returned.  So, we create a context that
-    can be adapted to `ISiteManager` using the `__conform__` API.
+    If the context passed to `getSiteManager()` is not `None`, it is
+    adapted to `IComponentLookup` and this adapter returned.  So, we
+    create a context that can be adapted to `IComponentLookup` using
+    the `__conform__` API.
 
     Let's create the simplest stub-implementation of a site manager possible:
 
@@ -206,7 +208,7 @@
     Now create a context that knows how to adapt to our newly created site
     manager.
 
-      >>> context = ConformsToISiteManager(sitemanager)
+      >>> context = ConformsToIComponentLookup(sitemanager)
 
     Now make sure that the `getSiteManager()` API call returns the correct
     site manager.
@@ -214,7 +216,7 @@
       >>> component.getSiteManager(context) is sitemanager
       True
 
-    Using a context that is not adaptable to `ISiteManager` should fail.
+    Using a context that is not adaptable to `IComponentLookup` should fail.
 
       >>> component.getSiteManager(ob) #doctest: +NORMALIZE_WHITESPACE
       Traceback (most recent call last):
@@ -248,17 +250,17 @@
     We now have to create a site manager (other than the default global one)
     with which we can register adapters for `I1`.
 
-      >>> from zope.component.site import GlobalSiteManager
-      >>> sitemanager = GlobalSiteManager()
+      >>> from zope.component.globalregistry import BaseGlobalComponents
+      >>> sitemanager = BaseGlobalComponents()
 
     Now we create a new `context` that knows how to get to our custom site
     manager.
 
-      >>> context = ConformsToISiteManager(sitemanager)
+      >>> context = ConformsToIComponentLookup(sitemanager)
 
     We now register an adapter from `I1` to `I3`:
 
-      >>> sitemanager.provideAdapter((I1,), I3, '', lambda x: 43)
+      >>> sitemanager.registerAdapter(lambda x: 43, (I1,), I3, '')
 
     If an object implements the interface you want to adapt to,
     `getAdapterInContext()` should simply return the object.
@@ -327,14 +329,14 @@
     Now get the global site manager and register an adapter from `I1` to `I2`
     without a name:
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     (I1,), I2, '', Comp)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, (I1,), I2, '')
 
     You should get a sensible error message if you forget that the 'requires'
     argument is supposed to be a sequence
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     I1, I2, '', Comp)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, I1, I2, '')
       Traceback (most recent call last):
         ...
       TypeError: the required argument should be a list of interfaces, not a single interface
@@ -356,8 +358,8 @@
 
     First, we need to register an adapter:
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     [I1], I2, '', Comp)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, [I1], I2, '')
 
     Then we try to adapt `ob` to provide an `I2` interface by calling the `I2`
     interface with the obejct as first argument:
@@ -389,8 +391,8 @@
 
     First we register some named adapter:
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     [I1], I2, 'foo', lambda x: 0)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     lambda x: 0, [I1], I2, 'foo')
 
     If an adapter isn't registered for the given object and interface,
     and you provide no default, raise `ComponentLookupError`...
@@ -409,8 +411,8 @@
 
     But now we register an adapter for the object having the correct name
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     [I1], I2, 'bar', Comp)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, [I1], I2, 'bar')
 
     so that the lookup succeeds:
 
@@ -461,8 +463,8 @@
 
     Now we can register the multi-adapter using
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     (I1, I2), I3, '', DoubleAdapter)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     DoubleAdapter, (I1, I2), I3, '')
 
     Notice how the required interfaces are simply provided by a tuple. Now we
     can get the adapter:
@@ -480,8 +482,8 @@
     """Providing an adapter for None says that your adapter can adapt anything
     to `I2`.
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     (None,), I2, '', Comp)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, (None,), I2, '')
 
       >>> adapter = I2(ob)
       >>> adapter.__class__ is Comp
@@ -506,10 +508,10 @@
 
     Let's register some adapters first:
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     [I1], I2, '', Comp)
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     [None], I2, 'foo', Comp)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, [I1], I2, '')
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     Comp, [None], I2, 'foo')
 
     Now we get all the adapters that are registered for `ob` that provide
     `I2`:
@@ -521,8 +523,8 @@
     Note that the output doesn't include None values. If an adapter
     factory returns None, it is as if it wasn't present.
 
-      >>> component.getGlobalSiteManager().provideAdapter(
-      ...     [I1], I2, 'nah', lambda context: None)
+      >>> component.getGlobalSiteManager().registerAdapter(
+      ...     lambda context: None, [I1], I2, 'nah')
       >>> adapters = sorted(component.getAdapters((ob,), I2))
       >>> [(name, adapter.__class__.__name__) for name, adapter in adapters]
       [(u'', 'Comp'), (u'foo', 'Comp')]
@@ -553,7 +555,7 @@
 
     Now we declare `ob` to be the utility providing `I1`
 
-      >>> component.getGlobalSiteManager().provideUtility(I1, ob)
+      >>> component.getGlobalSiteManager().registerUtility(ob, I1)
 
     so that the component is now available:
 
@@ -566,7 +568,7 @@
 
     Just because you register an utility having no name
 
-      >>> component.getGlobalSiteManager().provideUtility(I1, ob)
+      >>> component.getGlobalSiteManager().registerUtility(ob, I1)
 
     does not mean that they are available when you specify a name:
 
@@ -585,8 +587,8 @@
 
     Registering the utility under the correct name
 
-      >>> component.getGlobalSiteManager().provideUtility(
-      ...     I1, ob, name='foo')
+      >>> component.getGlobalSiteManager().registerUtility(
+      ...     ob, I1, name='foo')
 
     really helps:
 
@@ -613,10 +615,10 @@
     Now we register the new utilities:
 
       >>> gsm = component.getGlobalSiteManager()
-      >>> gsm.provideUtility(I1, ob)
-      >>> gsm.provideUtility(I11, ob11)
-      >>> gsm.provideUtility(I1, ob_bob, name='bob')
-      >>> gsm.provideUtility(I2, Comp(2))
+      >>> gsm.registerUtility(ob, I1)
+      >>> gsm.registerUtility(ob11, I11)
+      >>> gsm.registerUtility(ob_bob, I1, name='bob')
+      >>> gsm.registerUtility(Comp(2), I2)
 
     We can now get all the utilities that provide interface `I1`:
 
@@ -669,18 +671,18 @@
     We need to make sure that it is possible to pickle the global site manager
     and its two global adapter registries.
 
-      >>> from zope.component import site
+      >>> from zope.component import globalSiteManager
       >>> import cPickle
-      >>> pickle = cPickle.dumps(site.globalSiteManager)
+      >>> pickle = cPickle.dumps(globalSiteManager)
       >>> sm = cPickle.loads(pickle)
-      >>> sm is site.globalSiteManager
+      >>> sm is globalSiteManager
       True
 
     Now let's ensure that the registries themselves can be pickled as well:
 
-      >>> pickle = cPickle.dumps(site.globalSiteManager.adapters)
+      >>> pickle = cPickle.dumps(globalSiteManager.adapters)
       >>> adapters = cPickle.loads(pickle)
-      >>> adapters is site.globalSiteManager.adapters
+      >>> adapters is globalSiteManager.adapters
       True
     """
 

Copied: Zope3/branches/jim-adapter/src/zope/component/utility.py (from rev 65920, Zope3/branches/jim-adapter/src/zope/component/bbb/utility.py)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/bbb/utility.py	2006-03-12 17:52:22 UTC (rev 65920)
+++ Zope3/branches/jim-adapter/src/zope/component/utility.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -0,0 +1,73 @@
+##############################################################################
+#
+# 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.1 (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.
+#
+##############################################################################
+import warnings
+
+warnings.warn("This module is deprecated and will go away in Zope 3.5.",
+              DeprecationWarning, 2)
+
+from zope.component.interfaces import Invalid, ComponentLookupError, IRegistry
+from zope.component.bbb.interfaces import IUtilityService
+from zope.component.service import GlobalService, IService, IServiceDefinition
+from zope.component.registry import UtilityRegistration
+import zope.interface
+
+class IGlobalUtilityService(IUtilityService, IRegistry):
+
+    def provideUtility(providedInterface, component, name='', info=''):
+        """Provide a utility
+
+        A utility is a component that provides an interface.
+        """
+
+class UtilityService(object):
+    """Provide IUtilityService
+
+    Mixin that superimposes utility management on adapter registery
+    implementation
+    """
+
+    def __init__(self, sitemanager=None):
+        self.__parent__ = None
+        if sitemanager is None:
+            from zope.component.site import GlobalSiteManager
+            sitemanager = GlobalSiteManager()
+        self.sm = sitemanager
+
+    def __getattr__(self, name):
+        attr = getattr(self.sm, name)
+        if attr is not None:
+            return attr
+
+        attr = getattr(self.sm.utilities, name)
+        if attr is not None:
+            return attr
+
+        raise AttributeError(name)
+
+
+class GlobalUtilityService(UtilityService, GlobalService):
+
+    zope.interface.implementsOnly(IGlobalUtilityService)
+
+    def __init__(self, sitemanager=None):
+        super(GlobalUtilityService, self).__init__(sitemanager)
+
+    def provideUtility(self, providedInterface, component, name='', info=''):
+        self.sm.provideUtility(providedInterface, component, name, info)
+
+    def registrations(self):
+        for reg in self.sm.registrations():
+            if isinstance(reg, UtilityRegistration):
+                if not reg.provided in (IService, IServiceDefinition): 
+                    yield reg

Modified: Zope3/branches/jim-adapter/src/zope/security/checker.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/security/checker.py	2006-03-12 21:46:52 UTC (rev 65930)
+++ Zope3/branches/jim-adapter/src/zope/security/checker.py	2006-03-12 21:46:54 UTC (rev 65931)
@@ -400,7 +400,8 @@
     The checker can be a Checker, or a function that, when called with
     an object, returns a Checker.
     """
-    if not isinstance(type_, (type, types.ClassType, types.ModuleType)):
+    if (not isinstance(type_, (type, types.ClassType, types.ModuleType))
+        and type(type_).__name__ != 'Module'):
         raise TypeError(
                 'type_ must be a type, class or module, not a %s' % type_)
     if type_ in _checkers:



More information about the Zope3-Checkins mailing list