[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - cache.py:1.9 caches.pt:1.9 connection.py:1.11 connections.pt:1.11 service.py:1.25 services.pt:1.8 view.py:1.14

Guido van Rossum guido@python.org
Thu, 1 May 2003 12:28:59 -0400


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

Modified Files:
	cache.py caches.pt connection.py connections.pt service.py 
	services.pt view.py 
Log Message:
More UI tweaks; use usageSummary() more consistently; add Activate buttons.


=== Zope3/src/zope/app/browser/services/cache.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/services/cache.py:1.8	Wed Apr 30 19:37:56 2003
+++ Zope3/src/zope/app/browser/services/cache.py	Thu May  1 12:28:28 2003
@@ -21,7 +21,8 @@
 from zope.app.interfaces.services.configuration import IUseConfiguration
 from zope.component import getAdapter, getView
 from zope.publisher.browser import BrowserView
-from zope.app.interfaces.services.configuration import Unregistered, Registered
+from zope.app.interfaces.services.configuration \
+     import Unregistered, Registered, Active
 from zope.app.traversing import traverse, getPath, getParent, objectName
 
 class Caches(BrowserView):
@@ -34,16 +35,34 @@
         In that case, issue a message.
         """
         todo = self.request.get("selected")
+        doActivate = self.request.get("Activate")
         doDeactivate = self.request.get("Deactivate")
         doDelete = self.request.get("Delete")
         if not todo:
-            if doDeactivate or doDelete:
+            if doActivate or doDeactivate or doDelete:
                 return "Please select at least one checkbox"
             return None
+        if doActivate:
+            return self._activate(todo)
         if doDeactivate:
             return self._deactivate(todo)
         if doDelete:
             return self._delete(todo)
+
+    def _activate(self, todo):
+        done = []
+        for name in todo:
+            registry = self.context.queryConfigurations(name)
+            obj = registry.active()
+            if obj is None:
+                # Activate the first registered configuration
+                obj = registry.info()[0]['configuration']
+                obj.status = Active
+                done.append(name)
+        if done:
+            return "Activated: " + ", ".join(done)
+        else:
+            return "All of the checked caches were already active"
 
     def _deactivate(self, todo):
         done = []


=== Zope3/src/zope/app/browser/services/caches.pt 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/services/caches.pt:1.8	Wed Apr 30 16:15:17 2003
+++ Zope3/src/zope/app/browser/services/caches.pt	Thu May  1 12:28:28 2003
@@ -49,8 +49,11 @@
     </tr>
   </table>
 
+  <input type="submit" name="Activate" value="Activate" />
   <input type="submit" name="Deactivate" value="Deactivate" />
+  &nbsp;
   <input type="submit" name="Delete" value="Delete" />
+  &nbsp;
   <input type="submit" name="Refresh" value="Refresh" />
 
 </form>


=== Zope3/src/zope/app/browser/services/connection.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/browser/services/connection.py:1.10	Wed Apr 30 19:37:56 2003
+++ Zope3/src/zope/app/browser/services/connection.py	Thu May  1 12:28:28 2003
@@ -21,7 +21,8 @@
 from zope.app.interfaces.services.configuration import IUseConfiguration
 from zope.component import getAdapter, getView
 from zope.publisher.browser import BrowserView
-from zope.app.interfaces.services.configuration import Unregistered, Registered
+from zope.app.interfaces.services.configuration \
+     import Unregistered, Registered, Active
 from zope.app.traversing import traverse, getPath, getParent, objectName
 
 class Connections(BrowserView):
@@ -34,16 +35,34 @@
         In that case, issue a message.
         """
         todo = self.request.get("selected")
+        doActivate = self.request.get("Activate")
         doDeactivate = self.request.get("Deactivate")
         doDelete = self.request.get("Delete")
         if not todo:
             if doDeactivate or doDelete:
                 return "Please select at least one checkbox"
             return None
+        if doActivate:
+            return self._activate(todo)
         if doDeactivate:
             return self._deactivate(todo)
         if doDelete:
             return self._delete(todo)
+
+    def _activate(self, todo):
+        done = []
+        for name in todo:
+            registry = self.context.queryConfigurations(name)
+            obj = registry.active()
+            if obj is None:
+                # Activate the first registered configuration
+                obj = registry.info()[0]['configuration']
+                obj.status = Active
+                done.append(name)
+        if done:
+            return "Activated: " + ", ".join(done)
+        else:
+            return "All of the checked connections were already active"
 
     def _deactivate(self, todo):
         done = []


=== Zope3/src/zope/app/browser/services/connections.pt 1.10 => 1.11 ===
--- Zope3/src/zope/app/browser/services/connections.pt:1.10	Wed Apr 30 16:14:56 2003
+++ Zope3/src/zope/app/browser/services/connections.pt	Thu May  1 12:28:28 2003
@@ -49,8 +49,11 @@
     </tr>
   </table>
 
+  <input type="submit" name="Activate" value="Activate" />
   <input type="submit" name="Deactivate" value="Deactivate" />
+  &nbsp;
   <input type="submit" name="Delete" value="Delete" />
+  &nbsp;
   <input type="submit" name="Refresh" value="Refresh" />
 
 </form>


=== Zope3/src/zope/app/browser/services/service.py 1.24 => 1.25 ===
--- Zope3/src/zope/app/browser/services/service.py:1.24	Wed Apr 30 19:37:56 2003
+++ Zope3/src/zope/app/browser/services/service.py	Thu May  1 12:28:28 2003
@@ -155,17 +155,35 @@
 
         In that case, issue a message.
         """
-        deletes = self.request.get("delete")
+        todo = self.request.get("selected")
+        doActivate = self.request.get("Activate")
         doDeactivate = self.request.get("Deactivate")
         doDelete = self.request.get("Delete")
-        if not deletes:
+        if not todo:
             if doDeactivate or doDelete:
                 return "Please select at least one checkbox"
             return None
+        if doActivate:
+            return self._activate(todo)
         if doDeactivate:
-            return self._deactivate(deletes)
+            return self._deactivate(todo)
         if doDelete:
-            return self._delete(deletes)
+            return self._delete(todo)
+
+    def _activate(self, todo):
+        done = []
+        for name in todo:
+            registry = self.context.queryConfigurations(name)
+            obj = registry.active()
+            if obj is None:
+                # Activate the first registered configuration
+                obj = registry.info()[0]['configuration']
+                obj.status = Active
+                done.append(name)
+        if done:
+            return "Activated: " + ", ".join(done)
+        else:
+            return "All of the checked services were alrady active"
 
     def _deactivate(self, todo):
         done = []


=== Zope3/src/zope/app/browser/services/services.pt 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/services/services.pt:1.7	Tue Apr 29 17:21:55 2003
+++ Zope3/src/zope/app/browser/services/services.pt	Thu May  1 12:28:28 2003
@@ -29,7 +29,7 @@
 
           <table>
             <tr tal:repeat="reg registries">
-              <td><input type="checkbox" name="delete:list"
+              <td><input type="checkbox" name="selected:list"
                          tal:attributes="value reg/name" /></td>
               <td>
                 <a href="(link to the active service)"
@@ -53,8 +53,11 @@
             </tr>
           </table>
 
+          <input type="submit" name="Activate" value="Activate" />
           <input type="submit" name="Deactivate" value="Deactivate" />
+	  &nbsp;
           <input type="submit" name="Delete" value="Delete" />
+	  &nbsp;
           <input type="submit" name="Refresh" value="Refresh" />
 
 	</form>


=== Zope3/src/zope/app/browser/services/view.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/browser/services/view.py:1.13	Thu May  1 11:51:24 2003
+++ Zope3/src/zope/app/browser/services/view.py	Thu May  1 12:28:28 2003
@@ -133,7 +133,7 @@
         if done:
             return "Activated: " + ", ".join(done)
         else:
-            return "None of the checked utilities were inactive"
+            return "All of the checked views were already active"
 
     def _deactivate(self, todo):
         done = []
@@ -146,7 +146,7 @@
         if done:
             return "Deactivated: " + ", ".join(done)
         else:
-            return "None of the checked utilities were active"
+            return "None of the checked views were active"
 
     def _delete(self, todo):
         errors = []