[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - add_default_services.pt:1.1.2.1 site_icon.gif:1.1.2.1 smf_icon.gif:1.1.2.1 addservicemanager.py:1.3.4.1 configure.zcml:1.40.4.1

Jim Fulton jim@zope.com
Thu, 17 Apr 2003 06:18:24 -0400


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

Modified Files:
      Tag: uk-april-2003-usability-branch
	addservicemanager.py configure.zcml 
Added Files:
      Tag: uk-april-2003-usability-branch
	add_default_services.pt site_icon.gif smf_icon.gif 
Log Message:
Checking Seb's sprint work into a branch

=== Added File Zope3/src/zope/app/browser/services/add_default_services.pt ===
<html metal:use-macro="views/standard_macros/page">
<head><title>Add services to site</title></head>
<body>
<div metal:fill-slot="body">

<p>You have now turned this folder into a site.  Sites are like folders, but they contain
   Service Managers.</p>

<p>Service Managers gather together a unique configuration of services for your site.  
   Services allow you
   to customize the behaviour of this folder and all its subfolders. </p>

<p>Inside the Service Manager are Site Management Folders.  These provide logical groupings
   of services and configurations.  There is a default Site Management Folder called 'default'.
</p>

<p>The most common service you are likely to add and configure is a Page Folder.  When you
   have connected a Page Folder to a particular interface, all
   Page Templates which you subsequently add will be views on these interfaces.
   </p>

<p>If you want to do this, enter a name for a new Page Folder below.  If you would prefer
   to add services and connect them up manually, you can add them to the
   <a href="++etc++site/default/@@contents.html">default Site Management Folder</a>.  
   Alternatively,
   add a new Site Management Folder to the <a href="++etc++site/@@contents.html">Service 
   Manager</a>, and add configurations to that.
</p>

<form tal:attributes="action request/URL" action="action.html"
      tal:define="doupdate view/update">

<div>Name for page folder: <input type="text" name="pagefolder_id"></div>

<input type="submit" name="UPDATE_SUBMIT" value="Add page folder"/>
</form>

</div></body></html>


=== Added File Zope3/src/zope/app/browser/services/site_icon.gif ===
  <Binary-ish file>

=== Added File Zope3/src/zope/app/browser/services/smf_icon.gif ===
  <Binary-ish file>

=== Zope3/src/zope/app/browser/services/addservicemanager.py 1.3 => 1.3.4.1 ===
--- Zope3/src/zope/app/browser/services/addservicemanager.py:1.3	Sun Mar 23 17:35:36 2003
+++ Zope3/src/zope/app/browser/services/addservicemanager.py	Thu Apr 17 06:17:54 2003
@@ -17,7 +17,13 @@
 
 from zope.publisher.browser import BrowserView
 from zope.app.services.service import ServiceManager
-
+from zope.component import getAdapter, getFactory
+from zope.app.traversing import traverse, traverseName
+from zope.app.interfaces.container import IZopeContainer
+from zope.app.interfaces.services.configuration import IConfigurationManagerContainer
+from zope.app.services.servicenames import Views
+from zope.app.services.service import ServiceConfiguration
+from zope.app.traversing import getPath, joinPath
 
 class AddServiceManager(BrowserView):
 
@@ -27,4 +33,53 @@
             raise ValueError(
                   'This folder already contains a service manager')
         self.context.setServiceManager(sm)
-        self.request.response.redirect("++etc++site/")
+        self.request.response.redirect("@@addDefaultServices.html")
+
+    def update(self):
+        if 'UPDATE_SUBMIT' in self.request:
+            # add the services the user wanted to
+            # the default SMF
+            pagefolder_id = self.request['pagefolder_id']
+            if pagefolder_id:
+                # add a View Service and a page folder
+                # possibly redirect to default SMF, or even to
+                # the Page Folder if added
+                
+                # XXX we are assuming that the servicemanager is an IContainer
+                # even though it doesn't need to be.  One solution would be to
+                # check it implements IContainer or adapt it to IContainer
+                # Actually, we don't care if it's a container or not, only that
+                # we can traverse to the name default via it, and get a site
+                # management folder
+                default_smf = traverse(self.context, '++etc++site/default')
+                default_smf_path = getPath(default_smf)
+                # make a new view service
+                view_factory = "zope.app.services.ViewService"
+                self.makeService('View-1', view_factory, default_smf)
+                
+                # configure view service
+                configuration_smf = getAdapter(default_smf, IConfigurationManagerContainer)
+                cm = configuration_smf.getConfigurationManager()
+                service_path = joinPath(default_smf_path, 'View-1')
+                configuration = ServiceConfiguration(Views,
+                                                     service_path,
+                                                     self.context)
+                key = cm.setObject("", configuration)
+                configuration = traverseName(cm, key)
+                configuration.status = 'Active'
+
+                # make a new page folder
+                pagefolder_factory = "zope.app.services.PageFolder"
+                self.makeService(pagefolder_id, pagefolder_factory, default_smf)
+                destination = joinPath(default_smf_path,
+                                       pagefolder_id,
+                                       '@@DefaultConfiguration.html')
+                self.request.response.redirect(destination)
+
+    def makeService(self, name, factory, smf):
+        """Create a service using the named factory in the given site management
+        folder."""
+        factory = getFactory(self.context, factory)
+        obj = factory()
+        container = getAdapter(smf,  IZopeContainer)
+        container.setObject(name, obj)        


=== Zope3/src/zope/app/browser/services/configure.zcml 1.40 => 1.40.4.1 ===
--- Zope3/src/zope/app/browser/services/configure.zcml:1.40	Tue Mar 25 13:31:48 2003
+++ Zope3/src/zope/app/browser/services/configure.zcml	Thu Apr 17 06:17:54 2003
@@ -345,8 +345,8 @@
       schema = "zope.app.interfaces.services.view.IPageConfiguration"
       name= "PageConfiguration"
       content_factory = ".view.PageConfiguration"
-      keyword_arguments = "forInterface class_ viewName permission"
-      set_before_add = "template layer"
+      keyword_arguments = "forInterface class_ viewName permission layer"
+      set_before_add = "template"
       label = "Configure a view page"
       permission="zope.ManageServices"
       fields="forInterface viewName
@@ -384,26 +384,41 @@
     title="ZPT Template"
     />
 
-<!-- Service Manager navigation action -->
+<!-- Service Manager navigation actions -->
+
+  <pages
+      for="zope.app.interfaces.services.service.IServiceManagerContainer"
+      permission="zope.ManageServices"
+      class="zope.app.browser.services.addservicemanager.AddServiceManager">
+
+    <page name="addServiceManager.html"
+          attribute="addServiceManager"
+          />
+
+    <page name="addDefaultServices.html"
+          template="add_default_services.pt"
+          />
+
+  </pages>
 
-<page
-    name="addServiceManager.html" 
-    for="zope.app.interfaces.services.service.IServiceManagerContainer"
-    permission="zope.ManageServices" 
-    class="zope.app.browser.services.addservicemanager.AddServiceManager"
-    attribute="addServiceManager" 
-    />
+
+
+<icon
+   name="zmi_icon"
+   for="zope.app.interfaces.services.service.IActiveServiceManagerContainer" 
+   file="site_icon.gif"
+   />
 
 <menuItems menu="zmi_actions"
     for="zope.app.interfaces.services.service.IServiceManagerContainer"
     >
 
-  <menuItem title="Manage Local Services"
+  <menuItem title="Go to Site Services"
             action="++etc++site/@@SelectedManagementView.html"
             filter="context/hasServiceManager"
             />
 
-  <menuItem title="Turn On Local Service Manager"
+  <menuItem title="Convert to Site"
             action="@@addServiceManager.html"
             filter="not:context/hasServiceManager"
              />
@@ -483,7 +498,7 @@
       for="zope.app.interfaces.services.service.IServiceManager"
       >
     <menuItem
-        title="Visit default package"
+        title="Go to default Site Management Folder"
         action="default/@@SelectedManagementView.html"
         permission="zope.ManageServices"
         />
@@ -565,6 +580,13 @@
   <page name="action.html" attribute="action" />
 
 </view>
+
+
+<icon
+   name="zmi_icon"
+   for="zope.app.interfaces.services.folder.ISiteManagementFolder" 
+   file="smf_icon.gif"
+   />
 
 <!-- ServiceConfiguration -->