[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.13.6.1 adapter.py:1.4.28.2 interfaces.py:1.14.6.1 servicenames.py:1.5.52.1 resource.py:NONE skin.py:NONE view.py:NONE

Jim Fulton cvs-admin at zope.org
Sun Nov 9 11:09:03 EST 2003


Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv15349/src/zope/component

Modified Files:
      Tag: adaptergeddon-branch
	__init__.py adapter.py interfaces.py servicenames.py 
Removed Files:
      Tag: adaptergeddon-branch
	resource.py skin.py view.py 
Log Message:
Created a global presentation service that replaces the 
global view, resource, and skin services.

Now look up presentation components by adapting from a request type,
rather than adapting to a presentation type.





=== Zope3/src/zope/component/__init__.py 1.13 => 1.13.6.1 ===
--- Zope3/src/zope/component/__init__.py:1.13	Sun Sep 21 13:34:06 2003
+++ Zope3/src/zope/component/__init__.py	Sun Nov  9 11:08:31 2003
@@ -22,7 +22,7 @@
 from zope.component.interfaces import IComponentArchitecture
 from zope.component.exceptions import ComponentLookupError
 from zope.component.service import serviceManager
-from zope.component.servicenames import Adapters, Skins, Resources
+from zope.component.servicenames import Adapters, Presentation
 from zope.component.servicenames import Factories
 
 # Try to be hookable. Do so in a try/except to avoid a hard dependence
@@ -132,48 +132,46 @@
 def getFactoryInterfaces(context, name):
     return getService(context, Factories).getInterfaces(name)
 
-# Skin service
 
-def getSkin(wrapped_object, name, view_type):
-    return getService(wrapped_object,
-                      Skins).getSkin(wrapped_object, name, view_type)
-
-# View service
+# Presentation service
 
 def getView(object, name, request, context=None):
     v = queryView(object, name, request, context=context)
     if v is not None:
         return v
-    
-    raise ComponentLookupError("Couldn't find view", context, name)
+
+    raise ComponentLookupError("Couldn't find view",
+                               name, object, context, request)
 
 def queryView(object, name, request, default=None, context=None):
     if context is None:
         context = object
-    return getService(context,
-                      'Views').queryView(object, name, request, default)
+    s = getService(context, Presentation)
+    return s.queryView(object, name, request, default=default)
 
 queryView = hookable(queryView)
 
 def getDefaultViewName(object, request, context=None):
-    if context is None:
-        context = object
-    return getService(context, 'Views').getDefaultViewName(object, request)
+    v = queryDefaultViewName(object, request, context=context)
+    if v is not None:
+        return v
+
+    raise ComponentLookupError("Couldn't find default view name",
+                               context, request)
 
 def queryDefaultViewName(object, request, default=None, context=None):
     if context is None:
         context = object
-    return getService(context,
-                      'Views').queryDefaultViewName(object, request, default)
-
-# Resource service
+    s = getService(context, Presentation)
+    return s.queryDefaultViewName(object, request, default)
 
 def getResource(wrapped_object, name, request):
-    return getService(wrapped_object,
-                      Resources).getResource(
-        wrapped_object, name, request)
-
-def queryResource(wrapped_object, name, request, default=None):
-    return getService(wrapped_object,
-                      Resources).queryResource(
-        wrapped_object, name, request, default)
+    v = queryResource(wrapped_object, name, request)
+    if v is not None:
+        return v
+
+    raise ComponentLookupError("Couldn't find resource", name, request)
+
+def queryResource(context, name, request, default=None):
+    s = getService(context, Presentation)
+    return s.queryResource(name, request, default)


=== Zope3/src/zope/component/adapter.py 1.4.28.1 => 1.4.28.2 ===
--- Zope3/src/zope/component/adapter.py:1.4.28.1	Thu Oct 16 17:42:38 2003
+++ Zope3/src/zope/component/adapter.py	Sun Nov  9 11:08:31 2003
@@ -30,7 +30,7 @@
         self.__adapters = SurrogateRegistry()
 
     def provideAdapter(self,
-                       forInterface, providedInterface, maker, name=None):
+                       forInterface, providedInterface, maker, name=u''):
         """see IGlobalAdapterService interface"""
 
         if not isinstance(maker, (list, tuple)):
@@ -45,7 +45,7 @@
         self.__adapters.provideAdapter(forInterface, providedInterface, maker,
                                        name)
 
-    def getAdapter(self, object, interface, name=None):
+    def getAdapter(self, object, interface, name=u''):
         """see IAdapterService interface"""
         result = self.queryAdapter(object, interface, name=name)
         if result is None:
@@ -62,7 +62,7 @@
         return result
 
 
-    def queryAdapter(self, object, interface, default=None, name=None):
+    def queryAdapter(self, object, interface, default=None, name=u''):
         """see IAdapterService interface"""
         if name:
             warnings.warn("The name argument to queryAdapter is deprecated",


=== Zope3/src/zope/component/interfaces.py 1.14 => 1.14.6.1 ===
--- Zope3/src/zope/component/interfaces.py:1.14	Sun Sep 21 13:34:08 2003
+++ Zope3/src/zope/component/interfaces.py	Sun Nov  9 11:08:31 2003
@@ -166,20 +166,7 @@
         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):
-        """Get a skin definition as a sequence of layers
-
-        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 ComponentLookupError
-
-        There is a predefined skin in the global skin service, '', with
-        a single layer, ''."""
-
-    # View service
+    # Presentation service
 
     def getView(object, name, request, context=None):
         """Get a named view for a given object.
@@ -232,8 +219,6 @@
 
         """
 
-    # Resource service
-
     def getResource(wrapped_object, name, request):
         """Get a named resource for a given request
 
@@ -505,13 +490,6 @@
     """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.
 
@@ -532,30 +510,6 @@
 
         """
 
-class IResourceService(Interface):
-
-    def getResource(object, name, request):
-        """Look up a named resource for a given request
-
-        The request must implement IPresentationRequest.
-
-        The object provides a place to look for placeful resources.
-
-        A ComponentLookupError will be
-        raised if the component can't be found.
-        """
-
-    def queryResource(object, name, request, default=None):
-        """Look up a named resource for a given request
-
-        The request must implement IPresentationRequest.
-
-        The object provides a place to look for placeful resources.
-
-        The default will be returned if the component can't be found.
-        """
-
-
 class IView(IPresentation, IContextDependent):
     """Views provide a connection between an external actor and an object
     """
@@ -572,85 +526,32 @@
         "stands in" for the user.
         """
 
+class IPresentationService(Interface):
 
-
-class IViewService(Interface):
-
-    def getView(object, name, request):
-        """Get a named view for a given object and request
-
+    def queryResource(name, request, providing=Interface, default=None):
+        """Look up a named resource for a given request
+        
         The request must implement IPresentationRequest.
-
-        The object also provides a place to look for placeful views.
-
-        A ComponentLookupError will be
-        raised if the component can't be found.
+        
+        The default will be returned if the component can't be found.
         """
 
-    def queryView(object, name, request, default=None):
+    def queryView(object, name, request, providing=Interface, default=None):
         """Look for a named view for a given object and request
 
         The request must implement IPresentationRequest.
 
-        The object also provides a place to look for placeful views.
-
-        The default will be returned
-        if the component can't be found.
-        """
-
-    def getDefaultViewName(object, request):
-        """Get the name of the default view for the object and request
-
-        The request must implement IPresentationRequest.
-
-        A NotFoundError will be raised if the suitable
-        default view name for the object cannot be found.
-        """
-
-    def queryDefaultViewName(object, request, default=None):
-        """Look for the name of the default view for the object and request
-
-        The request must implement IPresentationRequest.
-
-        The default will be returned if a suitable
-        default view name for the object cannot be found.
-        """
-
-class IGlobalViewService(IViewService):
-
-    def setDefaultViewName(i_required, i_provided, name):
-        """Add name to registry of default view names for interfaces given."""
-
-    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.
-
-        XXX I'm not sure if there are right.
-        The name is the view name.
-        The type is the presentation type.
-        """
-
-    def getRegisteredMatching(required_interfaces=None, presentation_type=None,
-                              viewName=None, layer=None):
-        """Return registration info matching keyword arg criteria.
-
-        Return is an iterable 5-tuples containing:
-        - required interface
-        - provided interface
-        - chain of factories
-        - layer
-        - view name
+        The default will be returned if the component can't be found.
         """
 
-class ISkinService(Interface):
-
-    def getSkin(object, name, view_type):
-        """Return the sequence of layers (names) making up the skin.
-
-        The object provides a place to look for placeful skin definitions.
-
-        If the skin was not defined, an empty sequence will be returned.
-        """
+    def queryMultiView(objects, name, request, providing=Interface,
+                       default=None):
+        """Adapt the given objects and request
+
+        The first argument is a tuple of objects to be adapted with the
+        request.
+        """
+        
+        
+        
+        


=== Zope3/src/zope/component/servicenames.py 1.5 => 1.5.52.1 ===
--- Zope3/src/zope/component/servicenames.py:1.5	Tue Feb 11 21:17:42 2003
+++ Zope3/src/zope/component/servicenames.py	Sun Nov  9 11:08:31 2003
@@ -20,7 +20,5 @@
 Adapters = 'Adapters'
 Interfaces = 'Interfaces'
 Utilities = 'Utilities'
-Skins = 'Skins'
-Views = 'Views'
-Resources = 'Resources'
+Presentation = 'Presentation'
 Factories = 'Factories'

=== Removed File Zope3/src/zope/component/resource.py ===

=== Removed File Zope3/src/zope/component/skin.py ===

=== Removed File Zope3/src/zope/component/view.py ===




More information about the Zope3-Checkins mailing list