[Checkins] SVN: zope.component/branches/tseaver-wo_zope_deferred/ Branch removing zope.deferred.

Tres Seaver tseaver at palladion.com
Tue Mar 3 16:55:37 EST 2009


Log message for revision 97465:
  Branch removing zope.deferred.
  

Changed:
  A   zope.component/branches/tseaver-wo_zope_deferred/
  U   zope.component/branches/tseaver-wo_zope_deferred/setup.py
  U   zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/__init__.py
  U   zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/_api.py
  D   zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/bbb/
  U   zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/interfaces.py
  U   zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/registry.py
  U   zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/tests.py

-=-
Modified: zope.component/branches/tseaver-wo_zope_deferred/setup.py
===================================================================
--- zope.component/trunk/setup.py	2009-03-03 20:43:41 UTC (rev 97460)
+++ zope.component/branches/tseaver-wo_zope_deferred/setup.py	2009-03-03 21:55:37 UTC (rev 97465)
@@ -62,7 +62,6 @@
     install_requires=['setuptools',
                       'zope.interface',
                       'zope.event',
-                      'zope.deferredimport',
                       ],
     include_package_data = True,
     zip_safe = False,

Modified: zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/__init__.py
===================================================================
--- zope.component/trunk/src/zope/component/__init__.py	2009-03-03 20:43:41 UTC (rev 97460)
+++ zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/__init__.py	2009-03-03 21:55:37 UTC (rev 97465)
@@ -15,37 +15,45 @@
 
 $Id$
 """
-import zope.deferredimport
-from zope.interface import moduleProvides, Interface
-from zope.interface import providedBy, implementedBy
+from zope.interface import Interface
+from zope.interface import implementedBy
+from zope.interface import moduleProvides
+from zope.interface import providedBy
+
 from zope.component.interfaces import IComponentArchitecture
+from zope.component.interfaces import IComponentLookup
 from zope.component.interfaces import IComponentRegistrationConvenience
-from zope.component.interfaces import IDefaultViewName
 from zope.component.interfaces import IFactory
-from zope.component.interfaces import ComponentLookupError
-from zope.component.interfaces import IComponentLookup
 
-zope.deferredimport.defineFrom(
-    'zope.component.globalregistry',
-    'globalSiteManager', 'getGlobalSiteManager',
-    'provideUtility', 'provideAdapter',
-    'provideSubscriptionAdapter', 'provideHandler',
-    )
+from zope.component.globalregistry import getGlobalSiteManager
+from zope.component.globalregistry import globalSiteManager
+from zope.component.globalregistry import provideAdapter
+from zope.component.globalregistry import provideHandler
+from zope.component.globalregistry import provideSubscriptionAdapter
+from zope.component.globalregistry import provideUtility
 
-zope.deferredimport.defineFrom(
-    'zope.component._api',
-    'getSiteManager', 'queryAdapterInContext', 'getAdapterInContext',
-    'getAdapter', 'queryAdapter', 'getMultiAdapter', 'queryMultiAdapter',
-    'getAdapters', 'subscribers', 'handle', 'adapter_hook',
-    'getUtility', 'queryUtility', 'getUtilitiesFor',
-    'getAllUtilitiesRegisteredFor',
-    'createObject', 'getFactoryInterfaces', 'getFactoriesFor',
-    )
+from zope.component._api import adapter_hook
+from zope.component._api import createObject
+from zope.component._api import getAdapter
+from zope.component._api import getAdapterInContext
+from zope.component._api import getAdapters
+from zope.component._api import getAllUtilitiesRegisteredFor
+from zope.component._api import getFactoriesFor
+from zope.component._api import getFactoryInterfaces
+from zope.component._api import getMultiAdapter
+from zope.component._api import getSiteManager
+from zope.component._api import getUtilitiesFor
+from zope.component._api import getUtility
+from zope.component._api import handle
+from zope.component._api import queryAdapter
+from zope.component._api import queryAdapterInContext
+from zope.component._api import queryMultiAdapter
+from zope.component._api import queryUtility
+from zope.component._api import subscribers
 
-zope.deferredimport.defineFrom(
-    'zope.component._declaration',
-    'adapter', 'adapts', 'adaptedBy',
-    )
+from zope.component._declaration import adaptedBy
+from zope.component._declaration import adapter
+from zope.component._declaration import adapts
 
 moduleProvides(IComponentArchitecture, IComponentRegistrationConvenience)
 __all__ = tuple(IComponentArchitecture)

Modified: zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/_api.py
===================================================================
--- zope.component/trunk/src/zope/component/_api.py	2009-03-03 20:43:41 UTC (rev 97460)
+++ zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/_api.py	2009-03-03 21:55:37 UTC (rev 97465)
@@ -15,18 +15,21 @@
 
 $Id$
 """
+import sys
 import types
-import sys
+
 from zope.interface import Interface
-from zope.interface import providedBy, implementedBy
+from zope.interface import implementedBy
+from zope.interface import providedBy
+
 from zope.component.interfaces import IComponentArchitecture
 from zope.component.interfaces import IComponentRegistrationConvenience
-from zope.component.interfaces import IDefaultViewName
 from zope.component.interfaces import IFactory
 from zope.component.interfaces import ComponentLookupError
 from zope.component.interfaces import IComponentLookup
-from zope.component.globalregistry import base
-from zope.component._declaration import adapter, adapts, adaptedBy
+from zope.component._declaration import adaptedBy
+from zope.component._declaration import adapter
+from zope.component._declaration import adapts
 
 # Try to be hookable. Do so in a try/except to avoid a hard dependency.
 try:
@@ -38,10 +41,13 @@
 # getSiteManager() returns a component registry.  Although the term
 # "site manager" is deprecated in favor of "component registry",
 # the old term is kept around to maintain a stable API.
-
+base = None
 @hookable
 def getSiteManager(context=None):
+    global base
     if context is None:
+        if base is None:
+            from zope.component.globalregistry import base
         return base
     else:
         # Use the global site manager to adapt context to `IComponentLookup`

Modified: zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/interfaces.py
===================================================================
--- zope.component/trunk/src/zope/component/interfaces.py	2009-03-03 20:43:41 UTC (rev 97460)
+++ zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/interfaces.py	2009-03-03 21:55:37 UTC (rev 97465)
@@ -16,12 +16,10 @@
 $Id$
 """
 
-import zope.deferredimport
-from zope import interface
+from zope.interface import Attribute
+from zope.interface import Interface
+from zope.interface import implements
 
-# BBB: Backward-compatibility; 12/05/2004
-from bbb.interfaces import *
-
 class ComponentLookupError(LookupError):
     """A component could not be found."""
 
@@ -32,23 +30,23 @@
     """A component is being used (registered) for the wrong interface."""
 
 
-class IObjectEvent(interface.Interface):
+class IObjectEvent(Interface):
     """An event related to an object.
 
     The object that generated this event is not necessarily the object
     refered to by location.
     """
 
-    object = interface.Attribute("The subject of the event.")
+    object = Attribute("The subject of the event.")
 
 
 class ObjectEvent(object):
-    interface.implements(IObjectEvent)
+    implements(IObjectEvent)
 
     def __init__(self, object):
         self.object = object
 
-class IComponentArchitecture(interface.Interface):
+class IComponentArchitecture(Interface):
     """The Component Architecture is defined by two key components: Adapters
     and Utiltities. Both are managed by site managers. All other components
     build on top of them.
@@ -108,7 +106,7 @@
     # Adapter API
 
     def getAdapter(object,
-                   interface=interface.Interface, name=u'',
+                   interface=Interface, name=u'',
                    context=None):
         """Get a named adapter to an interface for an object
 
@@ -145,7 +143,7 @@
         """
 
     def getMultiAdapter(objects,
-                        interface=interface.Interface, name='',
+                        interface=Interface, name='',
                         context=None):
         """Look for a multi-adapter to an interface for an objects
 
@@ -163,7 +161,7 @@
         named adapter methods with an empty string for a name.
         """
 
-    def queryAdapter(object, interface=interface.Interface, name=u'',
+    def queryAdapter(object, interface=Interface, name=u'',
                      default=None, context=None):
         """Look for a named adapter to an interface for an object
 
@@ -200,7 +198,7 @@
         """
 
     def queryMultiAdapter(objects,
-                          interface=interface.Interface, name=u'',
+                          interface=Interface, name=u'',
                           default=None,
                           context=None):
         """Look for a multi-adapter to an interface for objects
@@ -294,17 +292,17 @@
         create objects which implement the given interface.
         """
 
-class IComponentLookup(interface.Interface):
+class IComponentLookup(Interface):
     """Component Manager for a Site
 
     This object manages the components registered at a particular site. The
     definition of a site is intentionally vague.
     """
 
-    adapters = interface.Attribute(
+    adapters = Attribute(
         "Adapter Registry to manage all registered adapters.")
 
-    utilities = interface.Attribute(
+    utilities = Attribute(
         "Adapter Registry to manage all registered utilities.")
 
     def queryAdapter(object, interface, name=u'', default=None):
@@ -375,7 +373,7 @@
         returned.
         """
 
-class IComponentRegistrationConvenience(interface.Interface):
+class IComponentRegistrationConvenience(Interface):
     """API for registering components.
 
     CAUTION: This API should only be used from test or
@@ -457,7 +455,7 @@
         activity.
         """
 
-class IRegistry(interface.Interface):
+class IRegistry(Interface):
     """Object that supports component registry
     """
 
@@ -465,12 +463,12 @@
         """Return an iterable of component registrations
         """
 
-class IFactory(interface.Interface):
+class IFactory(Interface):
     """A factory is responsible for creating other components."""
 
-    title = interface.Attribute("The factory title.")
+    title = Attribute("The factory title.")
 
-    description = interface.Attribute("A brief description of the factory.")
+    description = Attribute("A brief description of the factory.")
 
     def __call__(*args, **kw):
         """Return an instance of the objects we're a factory for."""
@@ -484,15 +482,15 @@
         instance cannot be created, an empty Implements instance is returned.
         """
 
-class IRegistration(interface.Interface):
+class IRegistration(Interface):
     """A registration-information object
     """
 
-    registry = interface.Attribute("The registry having the registration")
+    registry = Attribute("The registry having the registration")
 
-    name = interface.Attribute("The registration name")
+    name = Attribute("The registration name")
 
-    info = interface.Attribute("""Information about the registration
+    info = Attribute("""Information about the registration
 
     This is information deemed useful to people browsing the
     configuration of a system. It could, for example, include
@@ -503,24 +501,24 @@
     """Information about the registration of a utility
     """
 
-    factory = interface.Attribute("The factory used to create the utility. Optional.")
-    component = interface.Attribute("The object registered")
-    provided = interface.Attribute("The interface provided by the component")
+    factory = Attribute("The factory used to create the utility. Optional.")
+    component = Attribute("The object registered")
+    provided = Attribute("The interface provided by the component")
 
 class _IBaseAdapterRegistration(IRegistration):
     """Information about the registration of an adapter
     """
 
-    factory = interface.Attribute("The factory used to create adapters")
+    factory = Attribute("The factory used to create adapters")
 
-    required = interface.Attribute("""The adapted interfaces
+    required = Attribute("""The adapted interfaces
 
     This is a sequence of interfaces adapters by the registered
     factory.  The factory will be caled with a sequence of objects, as
     positional arguments, that provide these interfaces.
     """)
 
-    provided = interface.Attribute("""The interface provided by the adapters.
+    provided = Attribute("""The interface provided by the adapters.
 
     This interface is implemented by the factory
     """)
@@ -535,9 +533,9 @@
 
 class IHandlerRegistration(IRegistration):
 
-    handler = interface.Attribute("An object called used to handle an event")
+    handler = Attribute("An object called used to handle an event")
 
-    required = interface.Attribute("""The handled interfaces
+    required = Attribute("""The handled interfaces
 
     This is a sequence of interfaces handled by the registered
     handler.  The handler will be caled with a sequence of objects, as
@@ -550,7 +548,7 @@
 class RegistrationEvent(ObjectEvent):
     """There has been a change in a registration
     """
-    interface.implements(IRegistrationEvent)
+    implements(IRegistrationEvent)
 
     def __repr__(self):
         return "%s event:\n%r" % (self.__class__.__name__, self.object)
@@ -560,7 +558,7 @@
     """
 
 class Registered(RegistrationEvent):
-    interface.implements(IRegistered)
+    implements(IRegistered)
 
 class IUnregistered(IRegistrationEvent):
     """A component or factory was unregistered
@@ -569,9 +567,9 @@
 class Unregistered(RegistrationEvent):
     """A component or factory was unregistered
     """
-    interface.implements(IUnregistered)
+    implements(IUnregistered)
 
-class IComponentRegistry(interface.Interface):
+class IComponentRegistry(Interface):
     """Register components
     """
 

Modified: zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/registry.py
===================================================================
--- zope.component/trunk/src/zope/component/registry.py	2009-03-03 20:43:41 UTC (rev 97460)
+++ zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/registry.py	2009-03-03 21:55:37 UTC (rev 97465)
@@ -17,15 +17,31 @@
 """
 
 import types
-import zope.interface.adapter
-from zope import component, interface
-from zope.component import interfaces
-import zope.interface.interfaces
-import zope.event
 
+from zope.interface import Interface
+from zope.interface import implementedBy
+from zope.interface import implements
+from zope.interface import implementsOnly
+from zope.interface import providedBy
+from zope.interface.adapter import AdapterRegistry
+from zope.interface.interfaces import ISpecification
+
+from zope.component.interfaces import ComponentLookupError
+from zope.component.interfaces import IAdapterRegistration
+from zope.component.interfaces import IComponents
+from zope.component.interfaces import IHandlerRegistration
+from zope.component.interfaces import IRegistrationEvent
+from zope.component.interfaces import ISubscriptionAdapterRegistration
+from zope.component.interfaces import IUtilityRegistration
+from zope.component.interfaces import Registered
+from zope.component.interfaces import Unregistered
+from zope.component._api import handle
+from zope.component._declaration import adapter
+from zope.event import notify
+
 class Components(object):
 
-    interface.implements(interfaces.IComponents)
+    implements(IComponents)
 
     def __init__(self, name='', bases=()):
         assert isinstance(name, basestring)
@@ -38,8 +54,8 @@
         return "<%s %s>" % (self.__class__.__name__, self.__name__)
 
     def _init_registries(self):
-        self.adapters = zope.interface.adapter.AdapterRegistry()
-        self.utilities = zope.interface.adapter.AdapterRegistry()
+        self.adapters = AdapterRegistry()
+        self.utilities = AdapterRegistry()
 
     def _init_registrations(self):
         self._utility_registrations = {}
@@ -92,7 +108,7 @@
             self.utilities.subscribe((), provided, component)
 
         if event:
-            zope.event.notify(interfaces.Registered(
+            notify(Registered(
                 UtilityRegistration(self, provided, name, component, info, factory)
                 ))
 
@@ -126,7 +142,7 @@
         if not subscribed:
             self.utilities.unsubscribe((), provided, component)
 
-        zope.event.notify(interfaces.Unregistered(
+        notify(Unregistered(
             UtilityRegistration(self, provided, name, component, *old[1:])
             ))
 
@@ -143,7 +159,7 @@
     def getUtility(self, provided, name=u''):
         utility = self.utilities.lookup((), provided, name)
         if utility is None:
-            raise interfaces.ComponentLookupError(provided, name)
+            raise ComponentLookupError(provided, name)
         return utility
 
     def getUtilitiesFor(self, interface):
@@ -163,7 +179,7 @@
         self.adapters.register(required, provided, name, factory)
 
         if event:
-            zope.event.notify(interfaces.Registered(
+            notify(Registered(
                 AdapterRegistration(self, required, provided, name,
                                     factory, info)
                 ))
@@ -189,7 +205,7 @@
         del self._adapter_registrations[(required, provided, name)]
         self.adapters.unregister(required, provided, name)
 
-        zope.event.notify(interfaces.Unregistered(
+        notify(Unregistered(
             AdapterRegistration(self, required, provided, name,
                                 *old)
             ))
@@ -208,7 +224,7 @@
     def getAdapter(self, object, interface, name=u''):
         adapter = self.adapters.queryAdapter(object, interface, name)
         if adapter is None:
-            raise interfaces.ComponentLookupError(object, interface, name)
+            raise ComponentLookupError(object, interface, name)
         return adapter
 
     def queryMultiAdapter(self, objects, interface, name=u'', default=None):
@@ -218,12 +234,12 @@
     def getMultiAdapter(self, objects, interface, name=u''):
         adapter = self.adapters.queryMultiAdapter(objects, interface, name)
         if adapter is None:
-            raise interfaces.ComponentLookupError(objects, interface, name)
+            raise ComponentLookupError(objects, interface, name)
         return adapter
 
     def getAdapters(self, objects, provided):
         for name, factory in self.adapters.lookupAll(
-            map(interface.providedBy, objects),
+            map(providedBy, objects),
             provided):
             adapter = factory(*objects)
             if adapter is not None:
@@ -244,7 +260,7 @@
         self.adapters.subscribe(required, provided, factory)
 
         if event:
-            zope.event.notify(interfaces.Registered(
+            notify(Registered(
                 SubscriptionRegistration(self, required, provided, name,
                                          factory, info)
                 ))
@@ -288,7 +304,7 @@
         self._subscription_registrations[:] = new
         self.adapters.unsubscribe(required, provided, factory)
 
-        zope.event.notify(interfaces.Unregistered(
+        notify(Unregistered(
             SubscriptionRegistration(self, required, provided, name,
                                      factory, '')
             ))
@@ -311,7 +327,7 @@
         self.adapters.subscribe(required, None, factory)
 
         if event:
-            zope.event.notify(interfaces.Registered(
+            notify(Registered(
                 HandlerRegistration(self, required, name, factory, info)
                 ))
 
@@ -347,7 +363,7 @@
         self._handler_registrations[:] = new
         self.adapters.unsubscribe(required, None, factory)
 
-        zope.event.notify(interfaces.Unregistered(
+        notify(Unregistered(
             HandlerRegistration(self, required, name, factory, '')
             ))
 
@@ -358,7 +374,7 @@
 
 
 def _getUtilityProvided(component):
-    provided = list(interface.providedBy(component))
+    provided = list(providedBy(component))
     if len(provided) == 1:
         return provided[0]
     raise TypeError(
@@ -366,7 +382,7 @@
         "and no provided interface was specified.")
 
 def _getAdapterProvided(factory):
-    provided = list(interface.implementedBy(factory))
+    provided = list(implementedBy(factory))
     if len(provided) == 1:
         return provided[0]
     raise TypeError(
@@ -384,17 +400,17 @@
                 "The adapter factory doesn't have a __component_adapts__ "
                 "attribute and no required specifications were specified"
                 )
-    elif zope.interface.interfaces.ISpecification.providedBy(required):
+    elif ISpecification.providedBy(required):
         raise TypeError("the required argument should be a list of "
                         "interfaces, not a single interface")
 
     result = []
     for r in required:
         if r is None:
-            r = interface.Interface
-        elif not zope.interface.interfaces.ISpecification.providedBy(r):
+            r = Interface
+        elif not ISpecification.providedBy(r):
             if isinstance(r, classTypes):
-                r = interface.implementedBy(r)
+                r = implementedBy(r)
             else:
                 raise TypeError("Required specification must be a "
                                 "specification or class."
@@ -405,7 +421,7 @@
 
 class UtilityRegistration(object):
 
-    interface.implements(interfaces.IUtilityRegistration)
+    implements(IUtilityRegistration)
 
     def __init__(self, registry, provided, name, component, doc, factory=None):
         (self.registry, self.provided, self.name, self.component, self.info,
@@ -426,7 +442,7 @@
 
 class AdapterRegistration(object):
 
-    interface.implements(interfaces.IAdapterRegistration)
+    implements(IAdapterRegistration)
 
     def __init__(self, registry, required, provided, name, component, doc):
         (self.registry, self.required, self.provided, self.name,
@@ -447,11 +463,11 @@
 
 class SubscriptionRegistration(AdapterRegistration):
 
-    interface.implementsOnly(interfaces.ISubscriptionAdapterRegistration)
+    implementsOnly(ISubscriptionAdapterRegistration)
 
 class HandlerRegistration(AdapterRegistration):
 
-    interface.implementsOnly(interfaces.IHandlerRegistration)
+    implementsOnly(IHandlerRegistration)
 
     def __init__(self, registry, required, name, handler, doc):
         (self.registry, self.required, self.name, self.handler, self.info
@@ -473,22 +489,18 @@
             )
 
 
- at component.adapter(interfaces.IUtilityRegistration,
-                   interfaces.IRegistrationEvent)
+ at adapter(IUtilityRegistration, IRegistrationEvent)
 def dispatchUtilityRegistrationEvent(registration, event):
-    component.handle(registration.component, event)
+    handle(registration.component, event)
 
- at component.adapter(interfaces.IAdapterRegistration,
-                   interfaces.IRegistrationEvent)
+ at adapter(IAdapterRegistration, IRegistrationEvent)
 def dispatchAdapterRegistrationEvent(registration, event):
-    component.handle(registration.factory, event)
+    handle(registration.factory, event)
 
- at component.adapter(interfaces.ISubscriptionAdapterRegistration,
-                   interfaces.IRegistrationEvent)
+ at adapter(ISubscriptionAdapterRegistration, IRegistrationEvent)
 def dispatchSubscriptionAdapterRegistrationEvent(registration, event):
-    component.handle(registration.factory, event)
+    handle(registration.factory, event)
 
- at component.adapter(interfaces.IHandlerRegistration,
-                   interfaces.IRegistrationEvent)
+ at adapter(IHandlerRegistration, IRegistrationEvent)
 def dispatchHandlerRegistrationEvent(registration, event):
-    component.handle(registration.handler, event)
+    handle(registration.handler, event)

Modified: zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/tests.py
===================================================================
--- zope.component/trunk/src/zope/component/tests.py	2009-03-03 20:43:41 UTC (rev 97460)
+++ zope.component/branches/tseaver-wo_zope_deferred/src/zope/component/tests.py	2009-03-03 21:55:37 UTC (rev 97465)
@@ -36,12 +36,6 @@
 # we should obviously make this more explicit
 import zope.component.event
 
-import zope.deferredimport
-zope.deferredimport.deprecated(
-    "Use zope.component.testing instead",
-    placelesssetup = "zope.component.testing",
-    )
-
 class I1(interface.Interface):
     pass
 class I2(interface.Interface):



More information about the Checkins mailing list