[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - serviceactivation.pt:1.1.2.1 configure.zcml:1.23.2.1 service.py:1.7.2.1 services.pt:1.3.10.1

Tim Peters tim.one@comcast.net
Thu, 6 Mar 2003 16:51:55 -0500


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

Modified Files:
      Tag: service-config-branch
	configure.zcml service.py services.pt 
Added Files:
      Tag: service-config-branch
	serviceactivation.pt 
Log Message:
Tim/Guido checkpoint.  SImplefied service configuraton and activation.

=== Added File Zope3/src/zope/app/browser/services/serviceactivation.pt ===
<html metal:use-macro="views/standard_macros/page">

<tal:block
    metal:fill-slot="headers"
    tal:define="global pagetip string:

    To activate a particular service implementation,
    check its radio button and click Update.

    "
    />


<div metal:fill-slot="body">

  <h2>
    <span tal:replace="view/serviceName" /> 
  </h2>

  <form>
    <table tal:define="registry view/listRegistry">

      <thead>
        <tr> <td></td> <td>service</td> <td>configure</td> </tr>
      </thead>

      <tbody>

        <tr tal:repeat="config registry">
          <td><input type="radio" name="Active" value="default/configure/1"
                     tal:attributes="value config/id;
                                     checked config/active" /></td>
          <td><a href="foo"
                 tal:content="config/name1"
                 tal:attributes="href config/link1">Implementation</a></td>
          <td><a href="foo"
                 tal:content="config/id"
                 tal:attributes="href config/link2">Configuration</a></td>
        </tr>

        <tr>
          <td><input type="radio" name="Active" value="None"
                     tal:attributes="checked view/isDisabled"></td>
          <td>Disable</td>
        </tr>
      
      </tbody>
  
    </table>

    <input type="submit" value="Update">

  </form>

</div>
</html>



=== Zope3/src/zope/app/browser/services/configure.zcml 1.23 => 1.23.2.1 ===
--- Zope3/src/zope/app/browser/services/configure.zcml:1.23	Tue Mar  4 12:13:12 2003
+++ Zope3/src/zope/app/browser/services/configure.zcml	Thu Mar  6 16:51:51 2003
@@ -565,7 +565,15 @@
      name="services.html"
      menu="zmi_views" title="Services"
      template="services.pt"
-     class=".namecomponentconfigurableview.NameComponentConfigurableView"
+     class=".service.ServiceSummary"
+     permission="zope.ManageServices"
+     />
+
+  <page
+     for="zope.app.interfaces.services.service.IServiceConfiguration"
+     name="serviceActivation.html"
+     template="serviceactivation.pt"
+     class=".service.ServiceActivation"
      permission="zope.ManageServices"
      />
 


=== Zope3/src/zope/app/browser/services/service.py 1.7 => 1.7.2.1 ===
--- Zope3/src/zope/app/browser/services/service.py:1.7	Mon Mar  3 18:16:04 2003
+++ Zope3/src/zope/app/browser/services/service.py	Thu Mar  6 16:51:51 2003
@@ -26,6 +26,7 @@
 from zope.app.interfaces.services.configuration import IConfiguration
 from zope.app.form.utility import setUpWidgets, getWidgetsDataForContent
 from zope.app.traversing import traverse, getPhysicalPathString
+from zope.app.traversing import getPhysicalPath
 from zope.app.interfaces.services.interfaces import ILocalService
 from zope.proxy.context import getWrapperContainer
 from zope.app.interfaces.services.configuration \
@@ -189,3 +190,72 @@
                 sc.status = Registered
 
         self.request.response.redirect("@@useConfiguration.html")
+
+class ServiceSummary(BrowserView):
+
+    """A view on the service manager."""
+
+    def listConfiguredServices(self):
+        names = list(self.context.listConfigurationNames())
+        names.sort()
+
+        items = []
+        for name in names:
+            registry = self.context.queryConfigurations(name)
+            assert registry
+            info = registry.info()
+            assert info
+            representative = info[0]['configuration']
+            link1 = str(getView(representative, 'absolute_url', self.request))
+
+            component_name = link2 = ""
+            if info[0]['active']:
+                component = representative.getComponent()
+                path = getPhysicalPath(component)
+                component_name = "/".join(path[-2:])
+                link2 = str(getView(component, 'absolute_url', self.request))
+
+            items.append({'name': name,
+                          'link1': link1,
+                          'component': component_name,
+                          'link2': link2,
+                         })
+
+        return items
+
+class ServiceActivation(BrowserView):
+
+    """A view on a service configuration.
+
+    This really wants to be a view on a configuration registry
+    containing service configurations, but registries don't have names,
+    so we make it a view on a configuration which only serves as a
+    representative."""
+
+    def serviceName(self):
+        return self.context.name
+
+    def isDisabled(self):
+        sm = getServiceManager(self.context)
+        registry = sm.queryConfigurationsFor(self.context)
+        return not registry.active()
+
+    def listRegistry(self):
+        sm = getServiceManager(self.context)
+        registry = sm.queryConfigurationsFor(self.context)
+        result = []
+        for info in registry.info():
+            configobj = info['configuration']
+            component = configobj.getComponent()
+            path = getPhysicalPath(component)
+            name1 = "/".join(path[-2:])
+            link1 = str(getView(component, 'absolute_url', self.request))
+            link2 = str(getView(configobj, 'absolute_url', self.request))
+            item = {'active': info['active'],
+                    'id':     info['id'],
+                    'name1':  name1,
+                    'link1':  link1,
+                    'link2':  link2,
+                    }
+            result.append(item)
+        return result


=== Zope3/src/zope/app/browser/services/services.pt 1.3 => 1.3.10.1 ===
--- Zope3/src/zope/app/browser/services/services.pt:1.3	Sun Dec 29 17:24:16 2002
+++ Zope3/src/zope/app/browser/services/services.pt	Thu Mar  6 16:51:51 2003
@@ -1,12 +1,11 @@
 <html metal:use-macro="views/standard_macros/page">
 
-<tal:block  
-    metal:fill-slot="headers" 
+<tal:block
+    metal:fill-slot="headers"
     tal:define="global pagetip string:
 
-    To add a service, add a service component to a package and then
-    add an active configuration for it to the package's configuration
-    object.
+    To add a service, click on the Add Service link at the
+    top of this page.
 
     "
     />
@@ -14,27 +13,49 @@
 
 <div metal:fill-slot="body">
 
-  <div metal:use-macro="view/indexMacros/macros/body">
-
-  <h2 metal:fill-slot="heading">
-    Services configured in this service manager.
+  <h2>
+    Configured service types in this service manager
   </h2>
 
-  <p metal:fill-slot="empty_text">No services have been configured</p>
-
-  <div metal:fill-slot="extra_top">
-
-    <p>For each service, the service name is given and all of the
-       components registered to provide the service are shown.  You
-       may select the component to provide the service or disable the
-       service.
-    </p>
+  <div tal:define="registries view/listConfiguredServices">
 
-    <p>Select a service name or a component name to visit the service
-       or component.
-    </p>
+      <p tal:condition="not:registries">No services are configured.</p>
 
-  </div>
+      <div tal:condition="registries">
+        <p>For each configured service type, the service name is given and
+           links to a menu for selecting the active service implementation.
+           If some service implementation is active for the service type,
+           a link to that implementation is also given.
+        </p>
+
+        <table>
+          <thead>
+            <tr> <td>Service type</td> <td>Provided by</td> </tr>
+          </thead>
+          <tbody>
+            <tr tal:repeat="reg registries">
+              <td>
+                <a href="xxx"
+                   tal:attributes="href string:${reg/link1}/@@serviceActivation.html"
+                   tal:content="reg/name">
+                  Foobar (the service type)
+                </a>
+              </td>
+              <td>
+                <a href="xxx"
+                   tal:condition="reg/component"
+                   tal:attributes="href reg/link2"
+                   tal:content="reg/component">
+                  Foobar-1 (the name of the active service)
+                </a>
+                <span tal:condition="not:reg/component">
+                  (disabled)
+                </span>
+              </td>
+            </tr>
+          <tbody>
+        </table>
+      </div>
 
   </div>
 </div>