[Checkins] SVN: zope.component/trunk/s Ugh. Fix borked merge.
Tres Seaver
tseaver at palladion.com
Wed Mar 4 20:14:57 EST 2009
Log message for revision 97507:
Ugh. Fix borked merge.
Changed:
U zope.component/trunk/setup.py
U zope.component/trunk/src/zope/component/__init__.py
U zope.component/trunk/src/zope/component/_api.py
D zope.component/trunk/src/zope/component/bbb/
U zope.component/trunk/src/zope/component/interfaces.py
U zope.component/trunk/src/zope/component/registry.py
U zope.component/trunk/src/zope/component/tests.py
-=-
Modified: zope.component/trunk/setup.py
===================================================================
--- zope.component/trunk/setup.py 2009-03-05 00:49:16 UTC (rev 97506)
+++ zope.component/trunk/setup.py 2009-03-05 01:14:57 UTC (rev 97507)
@@ -62,7 +62,6 @@
install_requires=['setuptools',
'zope.interface',
'zope.event',
- 'zope.deferredimport',
],
include_package_data = True,
zip_safe = False,
Modified: zope.component/trunk/src/zope/component/__init__.py
===================================================================
--- zope.component/trunk/src/zope/component/__init__.py 2009-03-05 00:49:16 UTC (rev 97506)
+++ zope.component/trunk/src/zope/component/__init__.py 2009-03-05 01:14:57 UTC (rev 97507)
@@ -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/trunk/src/zope/component/_api.py
===================================================================
--- zope.component/trunk/src/zope/component/_api.py 2009-03-05 00:49:16 UTC (rev 97506)
+++ zope.component/trunk/src/zope/component/_api.py 2009-03-05 01:14:57 UTC (rev 97507)
@@ -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
# Use the C implementation in zope.hookable, if available; fall back
# to our Python version if not.
@@ -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/trunk/src/zope/component/interfaces.py
===================================================================
--- zope.component/trunk/src/zope/component/interfaces.py 2009-03-05 00:49:16 UTC (rev 97506)
+++ zope.component/trunk/src/zope/component/interfaces.py 2009-03-05 01:14:57 UTC (rev 97507)
@@ -17,12 +17,10 @@
"""
__docformat__ = "reStructuredText"
-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."""
@@ -33,23 +31,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.
@@ -109,7 +107,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
@@ -146,7 +144,7 @@
"""
def getMultiAdapter(objects,
- interface=interface.Interface, name='',
+ interface=Interface, name='',
context=None):
"""Look for a multi-adapter to an interface for an objects
@@ -164,7 +162,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
@@ -201,7 +199,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
@@ -295,17 +293,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):
@@ -376,7 +374,7 @@
returned.
"""
-class IComponentRegistrationConvenience(interface.Interface):
+class IComponentRegistrationConvenience(Interface):
"""API for registering components.
CAUTION: This API should only be used from test or
@@ -458,7 +456,7 @@
activity.
"""
-class IRegistry(interface.Interface):
+class IRegistry(Interface):
"""Object that supports component registry
"""
@@ -466,12 +464,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."""
@@ -485,15 +483,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
@@ -504,24 +502,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
""")
@@ -536,9 +534,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
@@ -551,7 +549,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)
@@ -561,7 +559,7 @@
"""
class Registered(RegistrationEvent):
- interface.implements(IRegistered)
+ implements(IRegistered)
class IUnregistered(IRegistrationEvent):
"""A component or factory was unregistered
@@ -570,9 +568,9 @@
class Unregistered(RegistrationEvent):
"""A component or factory was unregistered
"""
- interface.implements(IUnregistered)
+ implements(IUnregistered)
-class IComponentRegistry(interface.Interface):
+class IComponentRegistry(Interface):
"""Register components
"""
@@ -983,3 +981,78 @@
A default view name is used to select a view when a user hasn't
specified one.
"""
+
+class IContextDependent(Interface):
+ """Components implementing this interface must have a context component.
+
+ Usually the context must be one of the arguments of the
+ constructor. Adapters and views are a primary example of context-dependent
+ components.
+ """
+
+ context = Attribute(
+ """The context of the object
+
+ This is the object being adapted, viewed, extended, etc.
+ """)
+
+
+class IPresentation(Interface):
+ """Presentation components provide interfaces to external actors
+
+ The are created for requests, which encapsulate external actors,
+ connections, etc.
+ """
+
+ request = Attribute(
+ """The request
+
+ The request is a surrogate for the user. It also provides the
+ presentation type and skin. It is of type
+ IPresentationRequest.
+ """)
+
+
+class IPresentationRequest(Interface):
+ """An IPresentationRequest provides methods for getting view meta data."""
+
+
+class IResource(IPresentation):
+ """Resources provide data to be used for presentation."""
+
+
+class IResourceFactory(Interface):
+ """A factory to create factories using the request."""
+
+ def __call__(request):
+ """Create a resource for a request
+
+ The request must be an IPresentationRequest.
+ """
+
+
+class IView(IPresentation, IContextDependent):
+ """Views provide a connection between an external actor and an object"""
+
+
+class IViewFactory(Interface):
+ """Objects for creating views"""
+
+ def __call__(context, request):
+ """Create an view (IView) object
+
+ The context aregument is the object displayed by the view. The
+ request argument is an object, such as a web request, that
+ "stands in" for the user.
+ """
+
+# When this code is removed, this needs to be undeprecated and moved
+# towards a private interface somewhere in zope.app.publisher. In
+# effect the Zope 3 core is still using IDefaultViewName at present,
+# even though it's in bbb.
+class IDefaultViewName(Interface):
+ """A string that contains the default view name
+
+ A default view name is used to select a view when a user hasn't
+ specified one.
+ """
Modified: zope.component/trunk/src/zope/component/registry.py
===================================================================
--- zope.component/trunk/src/zope/component/registry.py 2009-03-05 00:49:16 UTC (rev 97506)
+++ zope.component/trunk/src/zope/component/registry.py 2009-03-05 01:14:57 UTC (rev 97507)
@@ -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/trunk/src/zope/component/tests.py
===================================================================
--- zope.component/trunk/src/zope/component/tests.py 2009-03-05 00:49:16 UTC (rev 97506)
+++ zope.component/trunk/src/zope/component/tests.py 2009-03-05 01:14:57 UTC (rev 97507)
@@ -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