[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - configure.zcml:1.20.2.2 service.py:1.6.2.6

Guido van Rossum guido@python.org
Mon, 3 Mar 2003 15:07:53 -0500


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

Modified Files:
      Tag: use-config-branch
	configure.zcml service.py 
Log Message:
Created a new menu, "add_service", and moved all services into that
menu.  This way, the "add_component" menu isn't so big.  Downside is
that it takes an extra step to add a service.


=== Zope3/src/zope/app/browser/services/configure.zcml 1.20.2.1 => 1.20.2.2 ===
--- Zope3/src/zope/app/browser/services/configure.zcml:1.20.2.1	Mon Feb 24 18:36:55 2003
+++ Zope3/src/zope/app/browser/services/configure.zcml	Mon Mar  3 15:07:22 2003
@@ -17,10 +17,12 @@
        template="texttbentry.pt"/>
     </browser:pages>
 
-  <browser:menuItem menu="add_component"
+  <browser:menuItem
+     menu="add_service"
      for="zope.app.interfaces.container.IAdding" 
-     action="ErrorReportingService"  title='Error Reporting Service'
-     description='Error Reporting Service for Logging Errors'
+     action="ErrorReportingService"
+     title="Error Reporting Service"
+     description="Error Reporting Service for Logging Errors"
      />
   
   <browser:icon name="zmi_icon" 
@@ -51,7 +53,7 @@
       />
 
   <browser:menuItem
-      menu="add_component"
+      menu="add_service"
       for="zope.app.interfaces.container.IAdding"
       action="CachingService"
       title="Caching Service"
@@ -91,7 +93,7 @@
       />
 
   <browser:menuItem
-      menu="add_component" 
+      menu="add_service" 
       for="zope.app.interfaces.container.IAdding"
       action="Events"  title="Event Service"
       description=
@@ -106,9 +108,11 @@
 
 <!-- Role Service -->
 
-  <browser:menuItem menu="add_component"
+  <browser:menuItem
+     menu="add_service"
      for="zope.app.interfaces.container.IAdding"
-     action="RoleService"  title="Role Service" />
+     action="RoleService"
+     title="Role Service" />
 
   <browser:icon
       name="zmi_icon" 
@@ -167,9 +171,11 @@
 
     </browser:view>
 
-  <browser:menuItem menu="add_component"
+  <browser:menuItem
+       menu="add_service"
        for="zope.app.interfaces.container.IAdding"
-       action="AuthenticationService"  title="Simple Authentication Service"
+       action="AuthenticationService"
+       title="Simple Authentication Service"
        description="A Persistent Authentication Service"
        />
 
@@ -256,7 +262,7 @@
       template="useconfiguration.pt"
       class=".useconfiguration.UseConfiguration"
       permission="zope.ManageServices"
-      menu="zmi_views" title="Uses"
+      menu="zmi_views" title="Configurations"
       />
 
 
@@ -337,7 +343,7 @@
 
 <browser:menuItem
       for="zope.app.interfaces.container.IAdding"
-      menu="add_component"
+      menu="add_service"
       action="zope.app.services.AdapterService"
       title="Adapter Service"
       />
@@ -403,7 +409,7 @@
 
 <browser:menuItem
       for="zope.app.interfaces.container.IAdding"
-      menu="add_component"
+      menu="add_service"
       action="zope.app.services.ViewService"
       title="View Service"
       />
@@ -525,7 +531,7 @@
       />
 
   <browser:menuItem
-      menu="add_component"
+      menu="add_service"
       for="zope.app.interfaces.container.IAdding"
       action="ConnectionService"
       title="SQL Connection Service"
@@ -701,7 +707,8 @@
     <browser:page name="action.html" attribute="action" />
   </browser:view>
 
-  <browser:menuItem menu="add_component"
+  <browser:menuItem
+        menu="add_component"
         for="zope.app.interfaces.container.IAdding"
         action="zope.app.services.ConfigurationManager"
         title="Configuration"
@@ -809,7 +816,8 @@
      filter="context/configured"
      />
 
-  <browser:menuItem menu="add_component"
+  <browser:menuItem
+     menu="add_component"
      for="zope.app.interfaces.container.IAdding"
      action="zope.app.services.ViewPackage" 
      title="View Sub-Package" />
@@ -817,17 +825,19 @@
 <!-- Session service -->
 
   <browser:menuItem
-     menu="add_component"
+     menu="add_service"
      for="zope.app.interfaces.container.IAdding" 
      action="ISessionService"  title='Cookie Session Service'
      description='Simplistic session support using cookies' />
 
 <!-- Principal annotations (user data) service -->
 
-  <browser:menuItem menu="add_component"
+  <browser:menuItem
+     menu="add_service"
      for="zope.app.interfaces.container.IAdding" 
-     action="IPrincipalAnnotationService"  title='Principal Annotation Service'
-     description='Stores Annotations for Principals' 
+     action="IPrincipalAnnotationService"
+     title="Principal Annotation Service"
+     description="Stores Annotations for Principals" 
      />
 
 
@@ -843,10 +853,10 @@
     />
 
   <browser:menuItem
-      menu="add_component"
+      menu="add_service"
       for="zope.app.interfaces.container.IAdding"
       action="ObjectHub"
-      title='ObjectHub'
+      title="ObjectHub Service"
       description="An object hub, for cataloging, unique object ids, and 
                    more: use sparingly" 
       />
@@ -855,5 +865,28 @@
       name="zmi_icon"
       for="zope.app.interfaces.services.hub.IObjectHub" 
       file="hub.gif" />
+
+
+<!-- "Add Service" menu -->
+
+<browser:menuItem
+    menu="add_component"
+    for="zope.app.interfaces.container.IAdding"
+    action="../AddService"
+    title="Service"
+    description="Takes you to a menu of services to add"
+    permission="zope.ManageServices"
+    />
+
+  <browser:view
+     name="AddService"
+     for="zope.app.interfaces.services.package.IPackage"
+     permission="zope.ManageServices"
+     class="zope.app.browser.services.service.ServiceAdding">
+
+    <browser:page name="index.html"  attribute="index"  />
+    <browser:page name="action.html" attribute="action" />
+
+  </browser:view>
 
 </zopeConfigure>


=== Zope3/src/zope/app/browser/services/service.py 1.6.2.5 => 1.6.2.6 ===
--- Zope3/src/zope/app/browser/services/service.py:1.6.2.5	Mon Mar  3 13:28:16 2003
+++ Zope3/src/zope/app/browser/services/service.py	Mon Mar  3 15:07:22 2003
@@ -36,12 +36,15 @@
 
     menu_id = "add_component"
 
-    def add(self, content):
-        # Override so as to save a reference to the added object
-        self.added_object = ContextSuper(ComponentAdding, self).add(content)
-        return self.added_object
-
     def action(self, type_name, id):
+        if type_name == "../AddService":
+            # Special case
+            url = type_name
+            if id:
+                url += "?id=" + id
+            self.request.response.redirect(url)
+            return
+
         if not id:
             # Generate an id from the type name
             id = type_name
@@ -57,8 +60,24 @@
         # As a side effect, self.added_object is set by add() above.
         ContextSuper(ComponentAdding, self).action(type_name, id)
 
+
+class ServiceAdding(ComponentAdding):
+    """Adding a service."""
+
+    menu_id = "add_service"
+
+    def add(self, content):
+        # Override so as to save a reference to the added object
+        self.added_object = ContextSuper(ComponentAdding, self).add(content)
+        return self.added_object
+
+    def action(self, type_name, id):
+        # Call the superclass action() method.
+        # As a side effect, self.added_object is set by add() above.
+        ContextSuper(ServiceAdding, self).action(type_name, id)
+
         if not ILocalService.isImplementedBy(self.added_object):
-            return # It's not a service
+            raise TypeError("%s is not a local service" % self.added_object)
 
         # Collect all defined services interfaces that it implements.
         sm = getServiceManager(self.context)