[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IContextDependent.py:1.1.4.1 IPresentation.py:1.1.4.1 IPresentationRequest.py:1.1.4.1 IResourceFactory.py:1.1.4.1 IView.py:1.1.4.1 IViewFactory.py:1.1.4.1 ContextDependent.py:1.1.2.5 GlobalAdapterService.py:1.1.2.4 GlobalResourceService.py:1.1.2.3 GlobalSkinService.py:1.1.2.2 GlobalUtilityService.py:1.1.2.2 GlobalViewService.py:1.1.2.3 IAdapterService.py:1.1.2.6 IPlacefulComponentArchitecture.py:1.1.2.2 IResourceService.py:1.1.2.5 IServiceManager.py:1.1.2.2 IUtilityService.py:1.1.2.6 IViewService.py:1.1.2.9 ServiceManagerContainer.py:1.1.2.8 __init__.py:1.1.6.22 component-meta.zcml:NONE component.zcml:NONE metaConfigure.py:NONE
Jim Fulton
jim@zope.com
Fri, 7 Jun 2002 10:41:54 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv12187/lib/python/Zope/ComponentArchitecture
Modified Files:
Tag: Zope-3x-branch
ContextDependent.py GlobalAdapterService.py
GlobalResourceService.py GlobalSkinService.py
GlobalUtilityService.py GlobalViewService.py
IAdapterService.py IPlacefulComponentArchitecture.py
IResourceService.py IServiceManager.py IUtilityService.py
IViewService.py ServiceManagerContainer.py __init__.py
Added Files:
Tag: Zope-3x-branch
IContextDependent.py IPresentation.py IPresentationRequest.py
IResourceFactory.py IView.py IViewFactory.py
Removed Files:
Tag: Zope-3x-branch
component-meta.zcml component.zcml metaConfigure.py
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals):
- RenameAllowToRequire
- GroupClassRelatedDirectivesInClassDirective
- ViewInterfaceAndSimplification
- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes
- TwoArgumentViewConstructors
- ImplementsInZCML
- SimpleViewCreationInZCML
- RemoveGetView
- ReplaceProtectWithAllow
- ViewMethodsAsViews
- MergeProtectionAndComponentDefinitions
There were also various security fixes resulting of better integration
of security with components.
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/IContextDependent.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IContextDependent.py,v 1.1.4.1 2002/06/07 14:41:22 jim Exp $
"""
from Interface import Interface
from Interface.Attribute import Attribute
class IContextDependent(Interface):
context = Attribute(
"""The context of the object
This is the object being adapted, viewed, extemded, etc.
""")
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/IPresentation.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IPresentation.py,v 1.1.4.1 2002/06/07 14:41:22 jim Exp $
"""
from Interface import Interface
from Interface.Attribute import Attribute
class IPresentation(Interface):
"""Presentation components provide interfaces to external actors
The are created for requests, which encapsulate external actors,
connections, etc.
"""
request = Attribute(
"""The request
The request is a surrogate for the user. It also provides the
presentation type and skin. It is of type
IPresentationRequest.
""")
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/IPresentationRequest.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IPresentationRequest.py,v 1.1.4.1 2002/06/07 14:41:22 jim Exp $
"""
from Interface import Interface
class IPresentationRequest(Interface):
"""An IPresentationRequest provides methods for getting view meta data.
"""
def getPresentationType():
"""Get a view type
The view type is expressed as an interface, as would be passed
to IViewService.getView.
"""
def getPresentationSkin():
"""Get the skin to be used for a request.
The skin is a string as would be passed
to IViewService.getView.
"""
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/IResourceFactory.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IResourceFactory.py,v 1.1.4.1 2002/06/07 14:41:22 jim Exp $
"""
from Interface import Interface
class IResourceFactory(Interface):
def __call__(request):
"""Create a resource for a request
The request must be an IPresentationRequest.
"""
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/IView.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IView.py,v 1.1.4.1 2002/06/07 14:41:22 jim Exp $
"""
from IContextDependent import IContextDependent
from IPresentation import IPresentation
class IView(IPresentation, IContextDependent):
"""Views provide a connection between an external actor and an object
"""
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/IViewFactory.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IViewFactory.py,v 1.1.4.1 2002/06/07 14:41:22 jim Exp $
"""
from Interface import Interface
class IViewFactory(Interface):
def __call__(object, request):
"""Create a view for the object and request
The request must be an IPresentationRequest.
"""
=== Zope3/lib/python/Zope/ComponentArchitecture/ContextDependent.py 1.1.2.4 => 1.1.2.5 ===
"""
+from IContextDependent import IContextDependent
+
class ContextDependent(object):
+ """standard boilerplate for context dependent objects"""
- """ standard boilerplate for context dependent objects"""
+ __implements__ = IContextDependent
def __init__(self, context):
- self.__context = context
+ self.context = context
- def getContext(self):
- return self.__context
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalAdapterService.py 1.1.2.3 => 1.1.2.4 ===
from Exceptions import ComponentLookupError
from IAdapterService import IAdapterService
-from Zope.ComponentArchitecture import _marker
from Zope.Proxy.ProxyIntrospection import removeAllProxies
class IGlobalAdapterService(IAdapterService):
@@ -49,14 +48,21 @@
"""see IGlobalAdapterService interface"""
self.__adapters.register(forInterface, providedInterface, maker)
- def getAdapter(self, object, interface, default=_marker):
+ def getAdapter(self, object, interface):
+ """see IAdapterService interface"""
+ result = self.queryAdapter(object, interface)
+ if result is None:
+ raise ComponentLookupError(object, interface)
+
+ return result
+
+ def queryAdapter(self, object, interface, default=None):
"""see IAdapterService interface"""
clean_object = removeAllProxies(object)
if interface.isImplementedBy(clean_object): return object
makers = self.__adapters.getForObject(clean_object, interface)
if makers is None:
- if default is not _marker: return default
- raise ComponentLookupError(object, interface)
+ return default
result = object
for maker in makers:
result = maker(result)
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalResourceService.py 1.1.2.2 => 1.1.2.3 ===
"""
-from IToIRegistry import IRegistry
+from IToIRegistry import DataRegistry
from Exceptions import ComponentLookupError
from Zope.ComponentArchitecture import getSkin, _marker
from IResourceService import IResourceService
class IGlobalResourceService(IResourceService):
- def provideResource(name, type, component, layer=''):
+ def provideResource(name, type, factory, layer='default'):
"""Provide a resource
A resource is an inependent component that provides a view
@@ -37,7 +37,7 @@
type -- The resource type, expressed as an interface
- component -- the resource component.
+ factory -- an IResourceFactory that computes a resource.
layer -- Optional skin layer. Layers are used to define skins.
"""
@@ -52,32 +52,37 @@
# Implementation methods for interface
# Zope.ComponentArchitecture.IResourceService.
- def getResource(self, object, name, type, default=_marker, skin=''):
+ def getResource(self, object, name, request):
'''See interface IResourceService'''
+
+ resource = self.queryResource(object, name, request)
+
+ if resource is None:
+ raise ComponentLookupError(object, name, type)
+
+ return resource
+
+ def queryResource(self, object, name, request, default=None):
+ '''See interface IResourceService'''
+
+ type = request.getPresentationType()
+ skin = request.getPresentationSkin()
+
for layername in getSkin(object, skin, type):
layer = self.__layers.get(layername)
if not layer: continue
reg = layer.get(name, None)
if reg is None: continue
- c = reg.getForObject(object, type)
- if c is None: continue
- return c
+ factory = reg.get(None, type)
+ if factory is None:
+ continue
- if default is _marker:
- raise ComponentLookupError(object, name, type)
+ return factory(request)
return default
-
- def getRequestResource(self, object, name, request, default=_marker):
- '''See interface IResourceService'''
-
- type = request.getViewType()
- skin = request.getViewSkin()
-
- return self.getResource(object, name, type, default, skin)
- def provideResource(self, name, type, component, layer=''):
+ def provideResource(self, name, type, factory, layer='default'):
'''See interface IGlobalResourceService'''
resources = self.__layers.get(layer)
@@ -86,9 +91,9 @@
reg = resources.get(name, None)
if reg is None:
- reg = resources[name] = IRegistry()
+ reg = resources[name] = DataRegistry()
- reg.register(type, component)
+ reg.register(type, factory)
_clear = __init__
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalSkinService.py 1.1.2.1 => 1.1.2.2 ===
"""
-_default = ('',)
+_default = ('default',)
class GlobalSkinService:
@@ -61,9 +61,8 @@
layers = reg.getForObject(clean_object, view_type)
if layers is not None:
return layers
- if not name:
- return _default
- return ('',)
+
+ return _default
_clear = __init__
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalUtilityService.py 1.1.2.1 => 1.1.2.2 ===
def getUtility(self, interface, default=None):
"""See IUtilityService interface"""
- c=self.__utilities.get(None, interface)
+ c = self.queryUtility(interface)
if c is None:
- if default: return default
raise ComponentLookupError(interface)
return c
+
+ def queryUtility(self, interface, default=None):
+ """See IUtilityService interface"""
+ c = self.__utilities.get(None, interface)
+ if c is None:
+ c = default
+ return c
_clear = __init__
@@ -60,4 +66,4 @@
# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
from Zope.Testing.CleanUp import addCleanUp
addCleanUp(_clear)
-del addCleanUp
\ No newline at end of file
+del addCleanUp
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalViewService.py 1.1.2.2 => 1.1.2.3 ===
the interfaces given.
'''
- def provideView(forInterface, name, type, maker, layer=''):
- ""
+
+ def provideView(forInterface, name, type, factory, layer='default'):
+ """Register a view factory
+
+ The factory is a sequence. The last object in the sequence
+ must be an IViewFactory. The other objects in the sequence
+ must be adapter factories.
+ """
class GlobalViewService:
@@ -81,47 +87,44 @@
return result
- def getView(self, object, name, type, default=_marker, skin=''):
+ def getView(self, object, name, request):
+ '''See interface IViewService'''
+ view = self.queryView(object, name, request)
+ if view is None:
+ raise ComponentLookupError(object, name, type)
+ return view
+
+ def queryView(self, object, name, request, default=None):
'''See interface IViewService'''
+
+ type = request.getPresentationType()
+ skin = request.getPresentationSkin()
+
clean_object=removeAllProxies(object)
+
for layername in getSkin(object, skin, type):
layer = self.__layers.get(layername)
if not layer:
continue
+
reg = layer.get(name, None)
if reg is None:
continue
+
makers = reg.getForObject(clean_object, type)
- if makers is None:
+ if not makers:
continue
result = object
- for maker in makers:
+ for maker in makers[:-1]:
result = maker(result)
- return result
-
- if default is _marker:
- raise ComponentLookupError(object, name, type)
- return default
-
- def getRequestView(self, object, name, request, default=_marker):
- '''See interface IViewService'''
-
- type = request.getViewType()
- skin = request.getViewSkin()
-
- view = self.getView(object, name, type, default, skin)
+ return makers[-1](result, request)
- # using self as marker
- setViewRequest = getattr(view, 'setViewRequest', self)
- if setViewRequest is not self:
- setViewRequest(request)
-
- return view
+ return default
- def provideView(self, forInterface, name, type, maker, layer=''):
+ def provideView(self, forInterface, name, type, maker, layer='default'):
'''See interface IGlobalViewService'''
views = self.__layers.get(layer)
@@ -134,23 +137,27 @@
reg.register(forInterface, type, maker)
- def getDefaultViewName(self, object, type, default=_marker):
+ def getDefaultViewName(self, object, request):
'''See interface IViewService'''
- name = self.__default_view_names.getForObject(object, type)
+
+ name = self.queryDefaultViewName(object, request)
+
if name is None:
- if default is not _marker:
- return default
raise NotFoundError, \
'No default view name found for object %s' % object
- return name
+ return name
- def getRequestDefaultViewName(self, object, request, default=_marker):
+ def queryDefaultViewName(self, object, request, default=None):
'''See interface IViewService'''
- return self.getDefaultViewName(object,
- request.getViewType(),
- default=default
- )
+
+ type = request.getPresentationType()
+ name = self.__default_view_names.getForObject(object, type)
+
+ if name is None:
+ name = default
+
+ return name
_clear = __init__
=== Zope3/lib/python/Zope/ComponentArchitecture/IAdapterService.py 1.1.2.5 => 1.1.2.6 ===
class IAdapterService(Interface):
- def getAdapter(object, interface, default=None):
+ def getAdapter(object, interface):
"""Look up an adapter that provides an interface for an object
A Zope.ComponentArchitecture.ComponentLookupError will be
raised if the component can't be found.
+ """
+
+ def queryAdapter(object, interface, default=None):
+ """Look up an adapter that provides an interface for an object
+
+ The default will be returned if the component can't be found.
"""
=== Zope3/lib/python/Zope/ComponentArchitecture/IPlacefulComponentArchitecture.py 1.1.2.1 => 1.1.2.2 ===
service manager if none is higher. if the context is the global
service manager, the function raises
- Zope.ComponentArchitecture.ComponentLookupError"""
+ Zope.ComponentArchitecture.ComponentLookupError."""
def getNextService(context, name):
"""Identical to getNextServiceManager, but will try to find the
@@ -58,20 +58,37 @@
# Utility service
- def getUtility(context, interface, default=None):
- """returns the nearest utility to the context that implements
- the specified interface. If one is not found, returns default
- if it is passed as an argument, or raises
- Zope.ComponentArchitecture.ComponentLookupError otherwise"""
+ def getUtility(context, interface):
+ """Get the utility that provides interface
+
+ Returns the nearest utility to the context that implements
+ the specified interface. If one is not found, raises
+ Zope.ComponentArchitecture.ComponentLookupError."""
+
+ def querytUtility(context, interface, default=None):
+ """Look for the utility that provides interface
+
+ Returns the nearest utility to the context that implements
+ the specified interface. If one is not found, returns default."""
# Adapter service
def getAdapter(object, interface, default=None, context=None):
- """returns the nearest adapter to the context that can adapt
+ """Get adapter to interface for object
+
+ Returns the nearest adapter to the context that can adapt
+ object to interface. If context is not specified, attempts to
+ use wrapping around object to specify a context. If a matching
+ adapter cannot be found, raises
+ Zope.ComponentArchitecture.ComponentLookupError."""
+
+ def queryAdapter(object, interface, default=None, context=None):
+ """Look for adapter to interface for object
+
+ Returns the nearest adapter to the context that can adapt
object to interface. If context is not specified, attempts to
use wrapping around object to specify a context. If a matching
- adapter cannot be found, returns default if it is passed as an argument, or raises
- Zope.ComponentArchitecture.ComponentLookupError otherwise"""
+ adapter cannot be found, returns default."""
# Factory service
@@ -101,40 +118,43 @@
# View service
- def getView(wrapped_object, name, view_type, default=None, skin=''):
- """Return the named view of a given type for an object and the
- given skin. The nearest one to the object is found. The type
- is expressed as an interface. If a
- matching view cannot be found, returns default
- if it is passed as an argument, or raises
- Zope.ComponentArchitecture.ComponentLookupError otherwise.
+ def getView(wrapped_object, name, request):
+ """Get a named view for a given object.
+
+ The request must implement IPresentationRequest: it provides
+ the view type and the skin name. The nearest one to the
+ object is found. If a matching view cannot be found, raises
+ Zope.ComponentArchitecture.ComponentLookupError.
+
"""
- def getRequestView(wrapped_object, name, request, default=None):
- """Look up a named view for a given request and object. The
- request must implement IViewRequest: it provides the view
+ def queryView(wrapped_object, name, request, default=None):
+ """Look for a named view for a given object.
+
+ The request must implement IPresentationRequest: it provides the view
type and the skin name. The nearest one to the object is
- found. If the view implements setViewRequest, that method is
- called with the Request. If a matching view cannot be found,
- returns default if it is passed as an argument, or raises
- Zope.ComponentArchitecture.ComponentLookupError otherwise.
- """
-
- def getDefaultViewName(wrapped_object, view_type, default=None):
- """Look up the name of the default view of the object for the
- given view type. The nearest one to the object is
- found. If a matching
- default view name cannot be found, returns the default argument
- if it is passed as an argument, or raises Zope.NotFoundError otherwise.
- """
-
- def getRequestDefaultViewName(wrapped_object, request, default=None):
- """Look up the name of the default view of the object for the
- given request. The request must implement IViewRequest, and
- provides the desired view type. The nearest one to the object is
- found. If a matching
- default view name cannot be found, returns the default argument
- if it is passed as an argument, or raises Zope.NotFoundError otherwise.
+ found. If a matching view cannot be found, returns default.
+
+ """
+
+ def getDefaultViewName(wrapped_object, request):
+ """Get the name of the default view for the object and request.
+
+ The request must implement IPresentationRequest, and provides the
+ desired view type. The nearest one to the object is found.
+ If a matching default view name cannot be found, raises
+ Zope.NotFoundError.
+
+ """
+
+ def queryDefaultViewName(wrapped_object, request, default=None):
+ """Look for the name of the default view for the object and request.
+
+ The request must implement IPresentationRequest, and provides the
+ desired view type. The nearest one to the object is found.
+ If a matching default view name cannot be found, returns the
+ default.
+
"""
def getViewDefinitions(context, name=None, used_for=None, \
@@ -161,30 +181,23 @@
# Resource service
- def getResource(wrapped_object, name, type, default=None, skin=''):
- """Look up a named resource of a given type
+ def getResource(wrapped_object, name, request):
+ """Get a named resource for a given request
- The type is expressed as an interface.
+ The request must implement IPresentationRequest.
The object provides a place to look for placeful resources.
- If the component can't be found, and a default argument was
- passed to the function, the default argument is returned.
-
A Zope.ComponentArchitecture.ComponentLookupError will be
- raised if the component can't be found otherwise.
+ raised if the component can't be found.
"""
- def getRequestResource(wrapped_object, name, request, default=None):
- """Look up a named resource for a given request
+ def queryResource(wrapped_object, name, request, default=None):
+ """Get a named resource for a given request
- The request must implement IViewRequest.
+ The request must implement IPresentationRequest.
The object provides a place to look for placeful resources.
- If the component can't be found, and a default argument was
- passed to the function, the default argument is returned.
-
- A Zope.ComponentArchitecture.ComponentLookupError will be
- raised if the component can't be found.
- """
\ No newline at end of file
+ If the component can't be found, the default is returned.
+ """
=== Zope3/lib/python/Zope/ComponentArchitecture/IResourceService.py 1.1.2.4 => 1.1.2.5 ===
class IResourceService(Interface):
- def getResource(object, name, type, default=None, skin=''):
- """Look up a named resource of a given type
+ def getResource(object, name, request):
+ """Look up a named resource for a given request
- The type is expressed as an interface.
+ The request must implement IPresentationRequest.
The object provides a place to look for placeful resources.
@@ -31,13 +31,18 @@
raised if the component can't be found.
"""
- def getRequestResource(object, name, request, default=None):
+ def queryResource(object, name, request, default=None):
"""Look up a named resource for a given request
- The request must implement IViewRequest.
+ The request must implement IPresentationRequest.
The object provides a place to look for placeful resources.
- A Zope.ComponentArchitecture.ComponentLookupError will be
- raised if the component can't be found.
+ The default will be returned if the component can't be found.
"""
+
+
+
+
+
+
=== Zope3/lib/python/Zope/ComponentArchitecture/IServiceManager.py 1.1.2.1 => 1.1.2.2 ===
def getService(name):
- """retrieve a service implementation
+ """Retrieve a service implementation
- Default implimentations search the context for the next
- ServiceService implimentation if the requested Service
- is not found.
-
- If none is found anywhere, raises ComponentLookupError
+ Raises ComponentLookupError if the service can't be found.
"""
=== Zope3/lib/python/Zope/ComponentArchitecture/IUtilityService.py 1.1.2.5 => 1.1.2.6 ===
class IUtilityService(Interface):
+ def getUtility(interface):
+ """Look up a utility that provides interface.
+
+ If one is not found, raises
+ Zope.ComponentArchitecture.ComponentLookupError."""
+
def getUtility(interface, default=None):
- """Look up a utility that provides an interface in this
- service, delegating to the next higher service if one is not
- found. If one is not found, returns default if not None, or raises
- Zope.ComponentArchitecture.ComponentLookupError otherwise"""
+ """Look up a utility that provides an interface.
+
+ If one is not found, returns default."""
=== Zope3/lib/python/Zope/ComponentArchitecture/IViewService.py 1.1.2.8 => 1.1.2.9 ===
class IViewService(Interface):
- def getView(object, name, type, default=None, skin=''):
- """Look up a named view of a given type for an object
+ def getView(object, name, request):
+ """Get a named view for a given object and request
- The type is expressed as an interface.
+ The request must implement IPresentationRequest.
The object also provides a place to look for placeful views.
@@ -31,33 +31,32 @@
raised if the component can't be found.
"""
- def getRequestView(object, name, request, default=None):
- """Look up a named view for a given request
+ def queryView(object, name, request, default=None):
+ """Look for a named view for a given object and request
- The request must implement IViewRequest.
+ The request must implement IPresentationRequest.
The object also provides a place to look for placeful views.
- If the view implements setViewRequest, that method is
- called with the Request.
-
- A Zope.ComponentArchitecture.ComponentLookupError will be
- raised if the component can't be found.
+ The default will be returned
+ if the component can't be found.
"""
- def getDefaultViewName(object, type, default=None):
- """Look up the name of the default view for the object
+ def getDefaultViewName(object, request):
+ """Get the name of the default view for the object and request
+
+ The request must implement IPresentationRequest.
A Zope.NotFoundError will be raised if the suitable
default view name for the object cannot be found.
"""
- def getRequestDefaultViewName(object, request, default=None):
- """Look up the name of the default view for the object
+ def queryDefaultViewName(object, request, default=None):
+ """Look for the name of the default view for the object and request
- The request must implement IViewRequest.
+ The request must implement IPresentationRequest.
- A Zope.NotFoundError will be raised if the suitable
+ The default will be returned if a suitable
default view name for the object cannot be found.
"""
@@ -78,22 +77,4 @@
The arguments may be given as keyword arguments and define a
query for the retrieval.
- """
-
-class IViewRequest(Interface):
- """An IViewRequest provides methods for getting view meta data.
- """
-
- def getViewType():
- """Get a view type
-
- The view type is expressed as an interface, as would be passed
- to IViewService.getView.
- """
-
- def getViewSkin():
- """Get the skin to be used for a request.
-
- The skin is a string as would be passed
- to IViewService.getView.
"""
=== Zope3/lib/python/Zope/ComponentArchitecture/ServiceManagerContainer.py 1.1.2.7 => 1.1.2.8 ===
def hasServiceManager(self):
'''See interface IReadServiceManagerContainer'''
-
return hasattr(self, '_ServiceManagerContainer__sm')
def getServiceManager(self, default=_marker):
=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.1.6.21 => 1.1.6.22 ===
def getService(context, name):
- #return getServiceManager(context).getService(name)
- # XXX we shouldn't need to do this; the above should be sufficient
- sv=getServiceManager(context).getService(name)
- if getWrapperContainer(sv) is None:
- return removeAllProxies(sv)
- return sv
+ return getServiceManager(context).getService(name)
def getServiceDefinitions(context):
return getServiceManager(context).getServiceDefinitions()
@@ -65,15 +60,25 @@
# Utility service
-def getUtility(context, interface, default=None):
- return getService(context, 'Utilities').getUtility(interface, default)
+def getUtility(context, interface):
+ return getService(context, 'Utilities').getUtility(interface)
+
+def queryUtility(context, interface, default=None):
+ return getService(context, 'Utilities').queryUtility(interface, default)
# Adapter service
-def getAdapter(object, interface, default=_marker, context=None):
+def getAdapter(object, interface, context=None):
+ if context is None:
+ context = object
+ return getService(context, 'Adapters').getAdapter(
+ object, interface)
+
+def queryAdapter(object, interface, default=_marker, context=None):
if context is None:
context = object
- return getService(context, 'Adapters').getAdapter(object, interface, default)
+ return getService(context, 'Adapters').queryAdapter(
+ object, interface, default)
# Factory service
@@ -91,25 +96,24 @@
# View service
-def getView(wrapped_object, name, view_type, default=_marker, skin=''):
+def getView(wrapped_object, name, request):
return getService(wrapped_object,
- 'Views').getView(wrapped_object, name, view_type,
- default, skin)
+ 'Views').getView(wrapped_object, name, request)
-def getRequestView(wrapped_object, name, request, default=_marker):
+def queryView(wrapped_object, name, request, default=None):
return getService(wrapped_object,
- 'Views').getRequestView(wrapped_object, name,
- request, default)
+ 'Views').queryView(wrapped_object, name,
+ request, default)
-def getDefaultViewName(wrapped_object, view_type, default=_marker):
+def getDefaultViewName(wrapped_object, request):
return getService(wrapped_object,
'Views').getDefaultViewName(wrapped_object,
- view_type, default)
+ request)
-def getRequestDefaultViewName(wrapped_object, request, default=_marker):
- return getService(wrapped_object,
- 'Views').getRequestDefaultViewName(wrapped_object,
- request, default)
+def queryDefaultViewName(wrapped_object, request, default=None):
+ return getService(wrapped_object,
+ 'Views').queryDefaultViewName(wrapped_object,
+ request, default)
def getViewDefinitions(context, name=None, used_for=None,
view_type=None, layer=None):
@@ -119,16 +123,15 @@
# Resource service
-def getResource(wrapped_object, name, type, default=_marker, skin=''):
- return getService(wrapped_object,
- 'Resources').getResource(wrapped_object, name,
- type, default, skin)
+def getResource(wrapped_object, name, request):
+ return getService(wrapped_object,
+ 'Resources').getResource(
+ wrapped_object, name, request)
-def getRequestResource(wrapped_object, name, request, default=_marker):
+def queryResource(wrapped_object, name, request, default=None):
return getService(wrapped_object,
- 'Resources').getRequestResource(wrapped_object, name,
- request,
- default)
+ 'Resources').queryResource(
+ wrapped_object, name, request, default)
#def _clear():
=== Removed File Zope3/lib/python/Zope/ComponentArchitecture/component-meta.zcml ===
=== Removed File Zope3/lib/python/Zope/ComponentArchitecture/component.zcml ===
=== Removed File Zope3/lib/python/Zope/ComponentArchitecture/metaConfigure.py ===