[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.30
adapter.py:1.13 interfaces.py:1.34 presentation.py:1.15
service.py:1.9 utility.py:1.14
Steve Alexander
steve at cat-box.net
Tue Apr 20 07:01:52 EDT 2004
Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv4440/src/zope/component
Modified Files:
__init__.py adapter.py interfaces.py presentation.py
service.py utility.py
Log Message:
Whitespace cleaning in the CA.
=== Zope3/src/zope/component/__init__.py 1.29 => 1.30 ===
--- Zope3/src/zope/component/__init__.py:1.29 Sun Apr 11 14:16:40 2004
+++ Zope3/src/zope/component/__init__.py Tue Apr 20 07:01:09 2004
@@ -58,7 +58,7 @@
def getUtilitiesFor(context, interface):
return getService(context, 'Utilities').getUtilitiesFor(interface)
-
+
# Adapter service
def getAdapter(object, interface, name='', context=None):
@@ -72,7 +72,7 @@
warnings.warn("The name argument to queryAdapter is deprecated",
DeprecationWarning, 2)
return queryNamedAdapter(object, interface, name, default, context)
-
+
conform = getattr(object, '__conform__', None)
if conform is not None:
try:
@@ -123,7 +123,7 @@
try:
adapters = getService(ob, Adapters)
except ComponentLookupError:
-
+
# Oh blast, no adapter service. We're probably just running
# from a test
@@ -145,7 +145,7 @@
context=None):
if context is None and objects:
context = objects[0]
-
+
try:
adapters = getService(context, Adapters)
except ComponentLookupError:
@@ -174,7 +174,7 @@
return getUtility(context, IFactory, name).getInterfaces()
def getFactoriesFor(context, interface):
- utils = getService(context, 'Utilities')
+ utils = getService(context, 'Utilities')
for (name, factory) in utils.getUtilitiesFor(IFactory):
interfaces = factory.getInterfaces()
try:
@@ -237,7 +237,7 @@
def getViewProviding(object, providing, request, context=None):
return getView(object, '', request, context, providing)
-
+
def queryViewProviding(object, providing, request, default=None,
context=None):
return queryView(object, '', request, default, context, providing)
=== Zope3/src/zope/component/adapter.py 1.12 => 1.13 ===
--- Zope3/src/zope/component/adapter.py:1.12 Sat Apr 17 10:33:51 2004
+++ Zope3/src/zope/component/adapter.py Tue Apr 20 07:01:09 2004
@@ -40,7 +40,7 @@
def subscribe(required, provided, factory, info=''):
"""Register a subscriber factory
-
+
:Parameters:
- `required`: a sequence of specifications for objects to be
adapted.
@@ -66,7 +66,7 @@
factory = self.lookup1(providedBy(object), interface, name)
if factory is not None:
return factory(object)
-
+
return default
def queryMultiAdapter(self, objects, interface, name='', default=None):
@@ -101,7 +101,7 @@
... pass
>>> class P2(P1):
... pass
-
+
>>> registry.register((R1, ), P2, 'bob', 'c1', 'd1')
>>> registry.register((R1, ), P2, '', 'c2', 'd2')
>>> registry.lookup((R2, ), P1, '')
@@ -113,14 +113,14 @@
... print registration
AdapterRegistration(('R1',), 'P2', '', 'c2', 'd2')
AdapterRegistration(('R1',), 'P2', 'bob', 'c1', 'd1')
-
+
"""
required = tuple(required)
self._registrations[(required, provided, name)] = AdapterRegistration(
required, provided, name, factory, info)
-
+
AdapterService.register(self, required, provided, name, factory)
-
+
def subscribe(self, required, provided, factory, info=''):
"""Register an subscriptions adapter
@@ -133,7 +133,7 @@
... pass
>>> class P2(P1):
... pass
-
+
>>> registry.subscribe((R1, ), P2, 'c1', 'd1')
>>> registry.subscribe((R1, ), P2, 'c2', 'd2')
>>> subscriptions = map(str, registry.subscriptions((R2, ), P1))
@@ -147,13 +147,13 @@
... print registration
SubscriptionRegistration(('R1',), 'P2', 'c1', 'd1')
SubscriptionRegistration(('R1',), 'P2', 'c2', 'd2')
-
+
"""
required = tuple(required)
registration = SubscriptionRegistration(
required, provided, factory, info)
-
+
self._registrations[(required, provided)] = (
self._registrations.get((required, provided), ())
+
@@ -173,7 +173,7 @@
class AdapterRegistration(object):
"""Registration for a simple adapter."""
-
+
def __init__(self, required, provided, name, value, doc=''):
(self.required, self.provided, self.name, self.value, self.doc
) = required, provided, name, value, doc
=== Zope3/src/zope/component/interfaces.py 1.33 => 1.34 ===
--- Zope3/src/zope/component/interfaces.py:1.33 Sat Apr 17 10:33:51 2004
+++ Zope3/src/zope/component/interfaces.py Tue Apr 20 07:01:09 2004
@@ -130,7 +130,8 @@
returned.
"""
- def queryNamedAdapter(object, interface, name, default=None, context=None):
+ def queryNamedAdapter(object, interface, name, default=None,
+ context=None):
"""Look for a named adapter to an interface for an object
Returns the nearest named adapter to the context that can adapt
@@ -167,7 +168,7 @@
Returns the subscribers for the context. If context is not
specified, attempts to use object to specify a context.
"""
-
+
# Factory service
@@ -265,19 +266,19 @@
If context is not specified, attempts to use the first object
to specify a context.
"""
-
+
def getViewProviding(object, providing, request, context=None):
"""Look for a view based on the interface it provides.
-
+
A call to this method is equivalent to:
-
+
getView(object, '', request, context, providing)
"""
-
+
def queryViewProviding(object, providing, request,
default=None, context=None):
"""Look for a view that provides the specified interface.
-
+
A call to this method is equivalent to:
queryView(object, '', request, default, context, providing)
@@ -515,9 +516,9 @@
def queryResource(name, request, providing=Interface, default=None):
"""Look up a named resource for a given request
-
+
The request must implement IPresentationRequest.
-
+
The default will be returned if the component can't be found.
"""
=== Zope3/src/zope/component/presentation.py 1.14 => 1.15 ===
--- Zope3/src/zope/component/presentation.py:1.14 Sat Apr 17 10:33:51 2004
+++ Zope3/src/zope/component/presentation.py Tue Apr 20 07:01:09 2004
@@ -59,7 +59,7 @@
def defineLayer(name):
"""Define a layer
"""
-
+
def provideAdapter(request_type, factory, name='', contexts=(),
providing=zope.interface.Interface, layer='default'):
"""Provide a presentation adapter
@@ -205,7 +205,7 @@
IGlobalPresentationService,
IRegistry,
)
-
+
def __init__(self):
self._layers = {'default': GlobalLayer(self, 'default')}
self._skins = {'default': [self._layers['default']]}
@@ -326,7 +326,7 @@
>>> s.defineLayer('custom', 'blah')
You can't define a layer that's already defined:
-
+
>>> s.defineLayer('custom')
Traceback (most recent call last):
...
@@ -351,7 +351,7 @@
This is a fairly low-level interface that supports both
resources and views.
-
+
"""
ifaces = []
@@ -362,12 +362,12 @@
context = zope.interface.implementedBy(context)
ifaces.append(context)
-
+
ifaces.append(request_type)
ifaces = tuple(ifaces)
-
+
reg = self._layers[layer]
-
+
reg.register(ifaces, providing, name, factory)
self._registrations[
@@ -375,14 +375,12 @@
] = PresentationRegistration(layer, ifaces, providing, name,
factory, info)
-
-
def queryResource(self, name, request, default=None,
providing=zope.interface.Interface):
"""Look up a named resource for a given request
-
+
The request must implement IPresentationRequest.
-
+
The default will be returned if the component can't be found.
"""
skin = request.getPresentationSkin() or self.defaultSkin
@@ -407,7 +405,6 @@
if r is not None:
return r
return default
-
def queryMultiView(self, objects, request,
providing=zope.interface.Interface, name='',
@@ -472,6 +469,7 @@
def GL(presentation_service, layer_name):
return presentation_service.queryLayer(layer_name)
+
class Layer(zope.interface.adapter.AdapterRegistry):
def queryNamedAdapter(self, obj, interface, name, default=None):
@@ -500,7 +498,7 @@
class SkinRegistration(object):
"""Registration for a global skin."""
-
+
def __init__(self, skin, layers, info):
self.skin, self.layers, self.doc = skin, layers, info
@@ -508,8 +506,7 @@
"""Representation of the object in a doctest-friendly format."""
return '%s.%s(%r, %r, %r)' % (
self.__class__.__module__, self.__class__.__name__,
- self.skin, self.layers, self.doc)
-
+ self.skin, self.layers, self.doc)
class LayerRegistration(object):
@@ -522,7 +519,7 @@
"""Representation of the object in a doctest-friendly format."""
return '%s.%s(%r, %r)' % (
self.__class__.__module__, self.__class__.__name__,
- self.layer, self.doc)
+ self.layer, self.doc)
class DefaultSkinRegistration(object):
@@ -535,7 +532,7 @@
"""Representation of the object in a doctest-friendly format."""
return '%s.%s(%r, %r)' % (
self.__class__.__module__, self.__class__.__name__,
- self.skin, self.doc)
+ self.skin, self.doc)
class PresentationRegistration(object):
=== Zope3/src/zope/component/service.py 1.8 => 1.9 ===
--- Zope3/src/zope/component/service.py:1.8 Fri Mar 5 17:09:25 2004
+++ Zope3/src/zope/component/service.py Tue Apr 20 07:01:09 2004
@@ -131,7 +131,8 @@
defineService = serviceManager.defineService
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+# Register our cleanup with Testing.CleanUp to make writing unit tests
+# simpler.
from zope.testing.cleanup import addCleanUp
addCleanUp(serviceManager._clear)
del addCleanUp
=== Zope3/src/zope/component/utility.py 1.13 => 1.14 ===
--- Zope3/src/zope/component/utility.py:1.13 Sat Apr 17 10:33:54 2004
+++ Zope3/src/zope/component/utility.py Tue Apr 20 07:01:09 2004
@@ -31,7 +31,7 @@
class UtilityService(AdapterRegistry):
"""Provide IUtilityService
-
+
Mixin that superimposes utility management on adapter registery
implementation
"""
@@ -57,7 +57,7 @@
if byname:
for item in byname.iteritems():
yield item
-
+
class GlobalUtilityService(UtilityService, GlobalService):
@@ -68,7 +68,7 @@
self._registrations = {}
def provideUtility(self, providedInterface, component, name='', info=''):
-
+
if not providedInterface.providedBy(component):
raise Invalid("The registered component doesn't implement "
"the promised interface.")
More information about the Zope3-Checkins
mailing list