[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.15 interfaces.py:1.16

Jim Fulton jim at zope.com
Wed Dec 17 05:07:30 EST 2003


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

Modified Files:
	__init__.py interfaces.py 
Log Message:
Added a providing keyword argument to the methods for retrieving views
and resources to allow lookup by provided interface, as well as name.


=== Zope3/src/zope/component/__init__.py 1.14 => 1.15 ===
--- Zope3/src/zope/component/__init__.py:1.14	Fri Nov 21 12:09:23 2003
+++ Zope3/src/zope/component/__init__.py	Wed Dec 17 05:06:59 2003
@@ -18,7 +18,7 @@
 
 import sys
 import warnings
-from zope.interface import moduleProvides
+from zope.interface import moduleProvides, Interface
 from zope.component.interfaces import IComponentArchitecture
 from zope.component.exceptions import ComponentLookupError
 from zope.component.service import serviceManager
@@ -135,19 +135,21 @@
 
 # Presentation service
 
-def getView(object, name, request, context=None):
-    v = queryView(object, name, request, context=context)
+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
 
     raise ComponentLookupError("Couldn't find view",
                                name, object, context, request)
 
-def queryView(object, name, request, default=None, context=None):
+def queryView(object, name, request,
+              default=None, context=None, providing=Interface):
     if context is None:
         context = object
     s = getService(context, Presentation)
-    return s.queryView(object, name, request, default=default)
+    return s.queryView(object, name, request,
+                       default=default, providing=providing)
 
 queryView = hookable(queryView)
 
@@ -165,13 +167,13 @@
     s = getService(context, Presentation)
     return s.queryDefaultViewName(object, request, default)
 
-def getResource(wrapped_object, name, request):
-    v = queryResource(wrapped_object, name, request)
+def getResource(wrapped_object, name, request, providing=Interface):
+    v = queryResource(wrapped_object, name, request, providing=providing)
     if v is not None:
         return v
 
     raise ComponentLookupError("Couldn't find resource", name, request)
 
-def queryResource(context, name, request, default=None):
+def queryResource(context, name, request, default=None, providing=Interface):
     s = getService(context, Presentation)
-    return s.queryResource(name, request, default)
+    return s.queryResource(name, request, default, providing=providing)


=== Zope3/src/zope/component/interfaces.py 1.15 => 1.16 ===
--- Zope3/src/zope/component/interfaces.py:1.15	Fri Nov 21 12:09:23 2003
+++ Zope3/src/zope/component/interfaces.py	Wed Dec 17 05:06:59 2003
@@ -168,7 +168,8 @@
 
     # Presentation service
 
-    def getView(object, name, request, context=None):
+    def getView(object, name, request, context=None,
+                providing=Interface):
         """Get a named view for a given object.
 
         The request must implement IPresentationRequest: it provides
@@ -181,7 +182,8 @@
 
         """
 
-    def queryView(object, name, request, default=None, context=None):
+    def queryView(object, name, request,
+                  default=None, context=None, providing=Interface):
         """Look for a named view for a given object.
 
         The request must implement IPresentationRequest: it provides the view
@@ -219,7 +221,7 @@
 
         """
 
-    def getResource(wrapped_object, name, request):
+    def getResource(wrapped_object, name, request, providing=Interface):
         """Get a named resource for a given request
 
         The request must implement IPresentationRequest.
@@ -231,7 +233,8 @@
 
         """
 
-    def queryResource(wrapped_object, name, request, default=None):
+    def queryResource(wrapped_object, name, request,
+                      default=None, providing=Interface):
         """Get a named resource for a given request
 
         The request must implement IPresentationRequest.




More information about the Zope3-Checkins mailing list