[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - bundle.pt:1.3 bundle.py:1.3

Guido van Rossum guido@python.org
Mon, 16 Jun 2003 13:55:00 -0400


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

Modified Files:
	bundle.pt bundle.py 
Log Message:
Report service dependencies.  Each service on which a bundle depends
can be either:

- present in this site (services at parent sites or global services
  don't count)

- present in this bundle (it will be activated when the bundle is
  activated)

- an unfulfilled dependency (and then you have to add one manually)


=== Zope3/src/zope/app/browser/services/bundle.pt 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/services/bundle.pt:1.2	Mon Jun 16 12:32:13 2003
+++ Zope3/src/zope/app/browser/services/bundle.pt	Mon Jun 16 13:54:59 2003
@@ -8,8 +8,25 @@
 
 <ul>
   <li tal:repeat="svc view/listServices">
-    <i tal:content="svc/service">Foo</i> service presently at
-    <a tal:content="svc/path" tal:attributes="href svc/path">/somewhere</a>
+    <i tal:content="svc/service">Foo</i> service
+    <span tal:condition="svc/insite">
+      present in site at
+      <a tal:content="svc/path" tal:attributes="href svc/path">/somewhere</a>
+    </span>
+    <span tal:condition="not:svc/insite">
+      <span tal:condition="svc/inbundle">
+        present in bundle at
+        <a tal:content="svc/inbundle"
+           tal:attributes="href svc/inbundle">somewhere</a>
+      </span>
+      <span tal:condition="not:svc/inbundle">
+        <font size="+1" color="red">
+          <i><b>UNFULFILLED DEPENDENCY</b></i>
+        </font>
+        <br><b>(You must add a <i tal:content="svc/service">Foo</i>
+        service to this site before you can activate this bundle)</b>
+      </span>
+    </span>
   </li>
 </ul>
 
@@ -22,12 +39,12 @@
   <ul>
     <tal:block tal:repeat="cnf view/listConfigurations">
       <li tal:condition="python: cnf['service'] == svc['service']">
-	<a tal:content="cnf/path" tal:attributes="href cnf/path">somewhere</a>
-	(status <b tal:content="cnf/status">Active</b>)
-	<br>
-	<i tal:content="cnf/usage">Usage summary</i>
-	implemented by
-	<i tal:content="cnf/implementation">Implementation summary</i>
+        <a tal:content="cnf/path" tal:attributes="href cnf/path">somewhere</a>
+        (status <b tal:content="cnf/status">Active</b>)
+        <br>
+        <i tal:content="cnf/usage">Usage summary</i>
+        implemented by
+        <i tal:content="cnf/implementation">Implementation summary</i>
       </li>
     </tal:block>
   </ul>


=== Zope3/src/zope/app/browser/services/bundle.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/services/bundle.py:1.2	Mon Jun 16 12:58:59 2003
+++ Zope3/src/zope/app/browser/services/bundle.py	Mon Jun 16 13:54:59 2003
@@ -32,12 +32,13 @@
 """
 
 from zope.app import zapi
-from zope.publisher.browser import BrowserView
 from zope.app.interfaces.container import IReadContainer
-from zope.app.interfaces.services.folder import ISiteManagementFolder
-from zope.app.interfaces.services.configuration import IConfigurationManager
 from zope.app.interfaces.services.configuration import IConfiguration
+from zope.app.interfaces.services.configuration import IConfigurationManager
+from zope.app.interfaces.services.folder import ISiteManagementFolder
+from zope.app.interfaces.services.service import IServiceConfiguration
 from zope.proxy import removeAllProxies
+from zope.publisher.browser import BrowserView
 
 class BundleView(BrowserView):
 
@@ -50,11 +51,26 @@
     # Methods called from the page template (bundle.pt)
 
     def listServices(self):
+        sitepath = zapi.getPath(zapi.getParent(self.context))
         infos = []
         for name in self.services:
-            svc = zapi.getService(self.context, name)
-            path = zapi.getPath(svc)
-            d = {"service": name, "path": path}
+            try:
+                svc = zapi.getService(self.context, name)
+            except:
+                svc = None
+            path = ""
+            insite = False
+            if svc:
+                try:
+                    path = zapi.getPath(svc)
+                except:
+                    path = ""
+                insite = path == sitepath or path.startswith(sitepath + "/")
+            inbundle = self.findServiceConfiguration(name)
+            d = {"service": name,
+                 "path": path,
+                 "insite": insite,
+                 "inbundle": inbundle}
             infos.append(d)
         return infos
 
@@ -71,6 +87,13 @@
 
     # The rest are helper methods
 
+    def findServiceConfiguration(self, name):
+        for path, obj in self.configurations:
+            if IServiceConfiguration.isImplementedBy(obj):
+                if obj.name == name:
+                    return path
+        return None
+
     def findConfigurations(self, f, prefix):
         alist = []
         for name, obj in f.items():
@@ -107,7 +130,7 @@
         return self.adjustServiceName(name)
 
     def adjustServiceName(self, name):
-        # XXX Strange...  There's no synbol for it in servicenames.py
+        # XXX Strange...  There's no symbol for it in servicenames.py
         if name == "Services":
             return ""
         else: