[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.26 interfaces.py:1.28

Philipp von Weitershausen philikon at philikon.de
Thu Mar 18 11:08:53 EST 2004


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

Modified Files:
	__init__.py interfaces.py 
Log Message:
- Added missing functions getMultiAdapter and getMultiView.

- Reformatted docstrings a bit.

- Got rid of one-letter variables for clarity.


=== Zope3/src/zope/component/__init__.py 1.25 => 1.26 ===
--- Zope3/src/zope/component/__init__.py:1.25	Thu Mar 18 07:19:26 2004
+++ Zope3/src/zope/component/__init__.py	Thu Mar 18 11:08:52 2004
@@ -134,6 +134,13 @@
 from zope.interface.interface import adapter_hooks
 adapter_hooks.append(interfaceAdapterHook)
 
+
+def getMultiAdapter(objects, interface, name=u'', context=None):
+    adapter = queryMultiAdapter(objects, interface, name, context=context)
+    if adapter is None:
+        raise ComponentLookupError(objects, interface)
+    return adapter
+
 def queryMultiAdapter(objects, interface, name=u'', default=None,
                       context=None):
     if context is None and objects:
@@ -188,9 +195,10 @@
 # Presentation service
 
 def getView(object, name, request, context=None, providing=Interface):
-    v = queryView(object, name, request, context=context, providing=providing)
-    if v is not None:
-        return v
+    view = queryView(object, name, request, context=context,
+                     providing=providing)
+    if view is not None:
+        return view
 
     raise ComponentLookupError("Couldn't find view",
                                name, object, context, request)
@@ -205,6 +213,15 @@
 
 queryView = hookable(queryView)
 
+def getMultiView(objects, name, request, providing=Interface, context=None):
+    view = queryMultiView(objects, name, request, context=context,
+                          providing=providing)
+    if view is not None:
+        return view
+
+    raise ComponentLookupError("Couldn't find view",
+                               name, object, context, request)
+
 def queryMultiView(objects, name, request, providing=Interface,
                    default=None, context=None):
     if context is None:
@@ -220,9 +237,9 @@
     return queryView(object, '', request, default, context, providing)
 
 def getDefaultViewName(object, request, context=None):
-    v = queryDefaultViewName(object, request, context=context)
-    if v is not None:
-        return v
+    view = queryDefaultViewName(object, request, context=context)
+    if view is not None:
+        return view
 
     raise ComponentLookupError("Couldn't find default view name",
                                context, request)
@@ -234,9 +251,9 @@
     return s.queryDefaultViewName(object, request, default)
 
 def getResource(wrapped_object, name, request, providing=Interface):
-    v = queryResource(wrapped_object, name, request, providing=providing)
-    if v is not None:
-        return v
+    view = queryResource(wrapped_object, name, request, providing=providing)
+    if view is not None:
+        return view
 
     raise ComponentLookupError("Couldn't find resource", name, request)
 


=== Zope3/src/zope/component/interfaces.py 1.27 => 1.28 ===
--- Zope3/src/zope/component/interfaces.py:1.27	Thu Mar 18 07:19:26 2004
+++ Zope3/src/zope/component/interfaces.py	Thu Mar 18 11:08:52 2004
@@ -102,6 +102,19 @@
         named adapter methods with an empty string for a name.
         """
 
+    def getMultiAdapter(objects, interface, name='', context=None):
+        """Look for a multi-adapter to an interface for an objects
+
+        Returns the nearest multi-adapter to the context that can
+        adapt objects to interface.  If context is not specified, the
+        first object, if any, is used.  If a matching adapter cannot
+        be found, raises ComponentLookupError.
+
+        The name consisting of an empty string is reserved for unnamed
+        adapters. The unnamed adapter methods will often call the
+        named adapter methods with an empty string for a name.
+        """
+
     def queryAdapter(object, interface, default=None, context=None):
         """Look for an adapter to an interface for an object
 
@@ -132,15 +145,13 @@
 
     def queryMultiAdapter(objects, interface, name='', default=None,
                           context=None):
-        """Look for a multi-adapter to an interface for an object
+        """Look for a multi-adapter to an interface for objects
 
         Returns the nearest multi-adapter to the context that can
-        adapt object to interface.  If context is not specified, the
+        adapt objects to interface.  If context is not specified, the
         first object, if any, is used.  If a matching adapter cannot
         be found, returns the default.
 
-        If a matching adapter cannot be found, returns the default.
-
         The name consisting of an empty string is reserved for unnamed
         adapters. The unnamed adapter methods will often call the
         named adapter methods with an empty string for a name.
@@ -220,24 +231,39 @@
                   default=None, context=None, providing=Interface):
         """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.
+        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.
 
-        If context is not specified, attempts to use 
-        object to specify a context.
+        If context is not specified, attempts to use object to specify
+        a context.
+        """
+
+    def getMultiView(objects, name, request, providing=Interface,
+                     context=None):
+        """Look for a multi-view for given objects
+
+        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
+        ComponentLookupError.
+
+        If context is not specified, attempts to use the first object
+        to specify a context.
         """
 
     def queryMultiView(objects, name, request, providing=Interface,
                        default=None, context=None):
         """Look for a multi-view for given objects
 
-        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.
+        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.
 
-        If context is not specified, attempts to use 
-        the first object to specify a context.
+        If context is not specified, attempts to use the first object
+        to specify a context.
         """
         
     def getViewProviding(object, providing, request, context=None):
@@ -272,13 +298,13 @@
     def queryDefaultViewName(object, request, default=None, context=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.
+        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.
 
-        If context is not specified, attempts to use 
-        object to specify a context.
+        If context is not specified, attempts to use object to specify
+        a context.
         """
 
     def getResource(wrapped_object, name, request, providing=Interface):




More information about the Zope3-Checkins mailing list