[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/interface - __init__.py:1.3 detail.pt:1.2

Jeremy Hylton jeremy@zope.com
Tue, 24 Jun 2003 11:39:23 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/services/interface
In directory cvs.zope.org:/tmp/cvs-serv21809/src/zope/app/browser/services/interface

Modified Files:
	__init__.py detail.pt 
Log Message:
Add preliminary ui for displaying service registrations.


=== Zope3/src/zope/app/browser/services/interface/__init__.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/services/interface/__init__.py:1.2	Mon Jun 23 12:14:19 2003
+++ Zope3/src/zope/app/browser/services/interface/__init__.py	Tue Jun 24 11:39:22 2003
@@ -15,6 +15,7 @@
 
 from zope.interface.interfaces import IMethod
 from zope.schema.interfaces import IField
+from zope.app.interfaces.services.interface import IInterfaceBasedRegistry
 
 from zope.app import zapi
 
@@ -32,28 +33,37 @@
         iface = self.context.getInterface(id)
 
         from zope.proxy import getProxiedObject
-        iface = getProxiedObject(iface)
+        self.iface = getProxiedObject(iface)
         
-        self.name = iface.__name__
+        self.name = self.iface.__name__
         # XXX the doc string needs some formatting for presentation
-        # XXX self.doc = iface.__doc__
-        self.doc = iface.getDoc()
+        # XXX self.doc = self.iface.__doc__
+        self.doc = self.iface.getDoc()
         self.methods = []
         self.schema = []
 
-        for name in iface:
-            defn = iface[name]
+        for name in self.iface:
+            defn = self.iface[name]
             if IMethod.isImplementedBy(defn):
                 self.methods.append(defn)
             elif IField.isImplementedBy(defn):
                 self.schema.append(defn)
 
     def getServices(self):
+        """Return an iterable of service dicts
+
+        where the service dicts contains keys "name" and "registrations."
+        registrations is a list of IRegistrations.
+        """
         sm = zapi.getServiceManager(self.context)
         for name, iface in sm.getServiceDefinitions():
             service = sm.queryService(name)
             if service is None:
                 continue
-            if queryAdapter(service, IXXX):
-                pass
-
+            registry = zapi.queryAdapter(service, IInterfaceBasedRegistry)
+            if registry is None:
+                continue
+            regs = list(registry.getRegistrationsForInterface(self.iface))
+            if regs:
+                yield {"name": name, "registrations": regs}
+            


=== Zope3/src/zope/app/browser/services/interface/detail.pt 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/services/interface/detail.pt:1.1	Mon Jun 23 12:14:19 2003
+++ Zope3/src/zope/app/browser/services/interface/detail.pt	Tue Jun 24 11:39:22 2003
@@ -28,6 +28,23 @@
     </ul>
 </div>
 
+<div tal:repeat="service view/getServices">
+    <h3 i18n:translate="">Registrations for 
+        <span tal:content="service/name" i18n:name="name">Name</span> 
+        service
+    </h3>
+
+    <ul>
+    <li tal:repeat="reg service/registrations">
+        <emph tal:content="reg/status">status</emph>
+        <strong tal:content="reg/usageSummary">usage</strong><br>
+	<span tal:content="reg/implementationSummary">impl</span>
+    </li>
+    </ul>
+
+</div>
+    
+
 </div>
 
 </html>