[Zope3-checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IComponentArchitecture.py:1.2 GlobalAdapterService.py:1.4 GlobalFactoryService.py:1.5 GlobalSkinService.py:1.4 GlobalViewService.py:1.6 __init__.py:1.8 IPlacefulComponentArchitecture.py:NONE IServiceManagerContainer.py:NONE ServiceManagerContainer.py:NONE
Jim Fulton
jim@zope.com
Thu, 1 Aug 2002 14:42:48 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv5741/lib/python/Zope/ComponentArchitecture
Modified Files:
GlobalAdapterService.py GlobalFactoryService.py
GlobalSkinService.py GlobalViewService.py __init__.py
Added Files:
IComponentArchitecture.py
Removed Files:
IPlacefulComponentArchitecture.py IServiceManagerContainer.py
ServiceManagerContainer.py
Log Message:
Removed dependcies of:
Zope.ComponentArchitecture
Zope.Configuration
Zope.Exceptions
Zope.Testing
on other packages, especially App, in preparation for making these
packages part of Zope 2 and useful outside of the Zope application.
In particular, all placeful service support was moved to
Zope.App.ComponentArchitecture.
Placeful service implementors should get the nextService and
nextServiceManager functions from
Zope.App.ComponentArchitecture.NextService.
=== Zope3/lib/python/Zope/ComponentArchitecture/IComponentArchitecture.py 1.1 => 1.2 ===
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.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$
+"""
+from Interface import Interface
+
+class IComponentArchitecture(Interface):
+ """The Component Architecture is defined by six key services,
+ all of which are managed by service managers.
+ """
+
+ # basic service manager tools
+
+ def getServiceManager(context):
+ """returns the nearest service manager to the context; if the
+ context is None the global service manager is always returned"""
+
+ def getService(context, name):
+ """returns the service defined by 'name' nearest to the context;
+ if the context is None the pertinent global service is always
+ returned"""
+
+ def getServiceDefinitions(context):
+ """returns a dictionary of the service definitions pertinent to
+ the given context, in the format {nameString: serviceInterface}.
+ If the context is None the global definitions will be returned.
+ The default behavior of placeful service managers is to include
+ service definitions above them, but this can be overridden"""
+
+ # Utility service
+
+ 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 queryUtility(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):
+ """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."""
+
+ # Factory service
+
+ def createObject(context, name, *args, **kwargs):
+ """finds the factory of the given name that is nearest to the
+ context, and passes the other given arguments to the factory
+ to create a new instance. Returns a reference to the new
+ object. If a matching factory cannot be found raises
+ Zope.ComponentArchitecture.ComponentLookupError"""
+
+ def getFactoryInterfaces(context, name):
+ """finds the factory of the given name that is nearest to the
+ context, and returns the interface or interface tuple that
+ object instances created by the named factory will implement."""
+
+ # Skin service
+
+ def getSkin(wrapped_object, name, view_type):
+ """returns the nearest skin (sequence of layer names) to the
+ object, as specified by the name and the view type (browser,
+ xml-rpc, etc.) as expressed by an interface. If a matching skin
+ is not found, raises
+ Zope.ComponentArchitecture.ComponentLookupError
+
+ There is a predefined skin in the global skin service, '', with
+ a single layer, ''."""
+
+ # View service
+
+ 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 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 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.
+
+ """
+
+ # Resource service
+
+ def getResource(wrapped_object, name, request):
+ """Get a named resource for a given request
+
+ 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.
+ """
+
+ def queryResource(wrapped_object, name, request, default=None):
+ """Get a named resource for a given request
+
+ The request must implement IPresentationRequest.
+
+ The object provides a place to look for placeful resources.
+
+ If the component can't be found, the default is returned.
+ """
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalAdapterService.py 1.3 => 1.4 ===
from Interface.Registry.AdapterRegistry import AdapterRegistry
from Exceptions import ComponentLookupError
from IAdapterService import IAdapterService
-from Zope.Proxy.ProxyIntrospection import removeAllProxies
class IGlobalAdapterService(IAdapterService):
@@ -68,14 +67,18 @@
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 interface.isImplementedBy(object):
+ return object
+
+ makers = self.__adapters.getForObject(object, interface)
+
if makers is None:
return default
+
result = object
for maker in makers:
result = maker(result)
+
return result
_clear = __init__
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalFactoryService.py 1.4 => 1.5 ===
from IFactory import IFactory
from IFactoryService import IFactoryService
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
-from Zope.Proxy.ProxyIntrospection import removeAllProxies
-
class IGlobalFactoryService(IFactoryService):
@@ -37,7 +35,7 @@
def provideFactory(self, name, factory):
"""See IGlobalFactoryService interface"""
- verifyObject(IFactory, removeAllProxies(factory))
+ verifyObject(IFactory, factory)
self.__factories[name] = factory
def createObject(self, name, *args, **kwargs):
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalSkinService.py 1.3 => 1.4 ===
from Interface.Registry.ImplementorRegistry import ImplementorRegistry
from Exceptions import ComponentLookupError
from ISkinService import ISkinService
-from Zope.Proxy.ProxyIntrospection import removeAllProxies
-
class IGlobalSkinService(ISkinService):
=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalViewService.py 1.5 => 1.6 ===
from Zope.ComponentArchitecture import getSkin
from IViewService import IViewService
from Zope.Exceptions import NotFoundError
-from Zope.Proxy.ProxyIntrospection import removeAllProxies
class IGlobalViewService(IViewService):
@@ -64,8 +63,6 @@
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:
@@ -75,7 +72,7 @@
if reg is None:
continue
- makers = reg.getForObject(clean_object, type)
+ makers = reg.getForObject(object, type)
if not makers:
continue
=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.7 => 1.8 ===
$Id$
"""
-from IPlacefulComponentArchitecture import IPlacefulComponentArchitecture
+from IComponentArchitecture import IComponentArchitecture
from Exceptions import ComponentLookupError
from GlobalServiceManager import serviceManager
-__implements__ = IPlacefulComponentArchitecture
-from Zope.Proxy.ContextWrapper import getWrapperContainer
-from Zope.Proxy.ProxyIntrospection import removeAllProxies
-
-
-# placeful component architecture functions
-
-# basic service manager tools
+__implements__ = IComponentArchitecture
def getServiceManager(context): # hookable
return getServiceManager_hook(context)
@@ -52,34 +45,6 @@
def getServiceDefinitions(context):
return getServiceManager(context).getServiceDefinitions()
-
-# placeful service manager convenience tools
-
-def getNextServiceManager(context): # hookable
- return getNextServiceManager_hook(context)
-
-def queryNextServiceManager(context, default=None):
- try:
- return getNextServiceManager_hook(context)
- except ComponentLookupError:
- return default
-
-def getNextServiceManager_hook(context): #default hook
- raise ComponentLookupError
-
-def getNextService(context, name):
- service = queryNextService(context, name)
- if service is None:
- raise ComponentLookupError('service', name)
- return service
-
-def queryNextService(context, name, default=None):
- try:
- sm = getNextServiceManager(context)
- except ComponentLookupError:
- return default
- return sm.queryService(name, default)
-
# Utility service
=== Removed File Zope3/lib/python/Zope/ComponentArchitecture/IPlacefulComponentArchitecture.py ===
=== Removed File Zope3/lib/python/Zope/ComponentArchitecture/IServiceManagerContainer.py ===
=== Removed File Zope3/lib/python/Zope/ComponentArchitecture/ServiceManagerContainer.py ===