[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - service.py:1.31 serviceactivation.pt:1.7

Guido van Rossum guido@python.org
Wed, 18 Jun 2003 16:12:41 -0400


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

Modified Files:
	service.py serviceactivation.pt 
Log Message:
A major change in the semantics of the ConfigurationRegistry class
(and its interface).  When you deactivate an entry, the next entry is
activated.  A None entry may occur (once) at any position.  The info()
method now has an optional keep_dummy argument, which, when True,
returns an info entry corresponding to the dummy None in the data.

This is done so that uninstalling a bundle has a more natural effect:
all the activations that were overridden by the bundle are reactivated
when the bundle is uninstalled.

It is possible that this breaks part of the UI; I've fixed the only
place in the UI that I'm aware of that uses this, the code for
activating services; but there may be other places.


=== Zope3/src/zope/app/browser/services/service.py 1.30 => 1.31 ===
--- Zope3/src/zope/app/browser/services/service.py:1.30	Wed Jun 18 12:02:50 2003
+++ Zope3/src/zope/app/browser/services/service.py	Wed Jun 18 16:12:10 2003
@@ -288,17 +288,32 @@
 
         # XXX this code path is not being tested
         result = []
-        for info in registry.info():
+        dummy = {'id': 'None',
+                 'active': False,
+                 'configuration': None,
+                 'name': '',
+                 'url': '',
+                 'config': '',
+                }
+        for info in registry.info(True):
             configobj = info['configuration']
-            component = configobj.getComponent()
-            path = zapi.getPath(component)
-            path = path.split("/")
-            info['name'] = "/".join(path[-2:])
-            info['url'] = str(
-                zapi.getView(component, 'absolute_url', self.request))
-            info['config'] = str(zapi.getView(configobj, 'absolute_url',
-                                         self.request))
+            if configobj is None:
+                info = dummy
+                dummy = None
+                if not result:
+                    info['active'] = True
+            else:
+                component = configobj.getComponent()
+                path = zapi.getPath(component)
+                path = path.split("/")
+                info['name'] = "/".join(path[-2:])
+                info['url'] = str(
+                    zapi.getView(component, 'absolute_url', self.request))
+                info['config'] = str(zapi.getView(configobj, 'absolute_url',
+                                             self.request))
             result.append(info)
+        if dummy:
+            result.append(dummy)
         return result
 
     def update(self):
@@ -319,7 +334,7 @@
             return "No change"
 
         if new_active is None:
-            old_active.status = Registered
+            registry.activate(None)
             return "Service deactivated"
         else:
             new_active.status = Active


=== Zope3/src/zope/app/browser/services/serviceactivation.pt 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/services/serviceactivation.pt:1.6	Mon Apr 28 12:52:07 2003
+++ Zope3/src/zope/app/browser/services/serviceactivation.pt	Wed Jun 18 16:12:10 2003
@@ -36,20 +36,15 @@
           <td><input type="radio" name="active" value="default/configure/1"
                      tal:attributes="value config/id;
                                      checked config/active" /></td>
-          <td><a href="foo"
+          <td tal:condition="not:config/name">Disabled</td>
+          <td tal:condition="config/name"><a href="foo"
                  tal:content="config/name"
                  tal:attributes="href config/url">Implementation</a>
           </td>
-          <td><a href="foo"
+          <td tal:condition="config/name"><a href="foo"
                  tal:content="config/id"
                  tal:attributes="href config/config">Registration</a>
           </td>
-        </tr>
-
-        <tr>
-          <td><input type="radio" name="active" value="None"
-                     tal:attributes="checked view/isDisabled"></td>
-          <td>Disable</td>
         </tr>
       
       </tbody>