[Zope-CVS] CVS: Packages3/workflow/browser - useprocessdefinitionconfig.pt:1.1 configure.zcml:1.6 definition.py:1.3 definition_index.pt:1.2 workflows.pt:1.2 addprocessdefinitionconfig.pt:NONE

Ulrich Eck ueck@net-labs.de
Wed, 19 Mar 2003 12:01:13 -0500


Update of /cvs-repository/Packages3/workflow/browser
In directory cvs.zope.org:/tmp/cvs-serv20767/browser

Modified Files:
	configure.zcml definition.py definition_index.pt workflows.pt 
Added Files:
	useprocessdefinitionconfig.pt 
Removed Files:
	addprocessdefinitionconfig.pt 
Log Message:
checkpoint (updates for use-config/local-utility-branch changes)
(ATTENTION: this will not work until Jim has merged the local-utility-branch)
Updated everything to match the current configuration machinery


=== Added File Packages3/workflow/browser/useprocessdefinitionconfig.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
  <div metal:fill-slot="body">

    <p>Configurations for this process definition:</p>

    <ul>

      <li tal:repeat="use view/uses">

	<a href="."
	   tal:attributes="href use/url">
          <span tal:replace="string:process definition ${use/name}" />
	</a>
	(<span tal:replace="use/status">Active</span>)

      </li>
    </ul>

    <p><a href="addConfiguration.html">Add a configuration for this process definition</a>

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


=== Packages3/workflow/browser/configure.zcml 1.5 => 1.6 ===
--- Packages3/workflow/browser/configure.zcml:1.5	Fri Feb  7 16:50:51 2003
+++ Packages3/workflow/browser/configure.zcml	Wed Mar 19 12:00:42 2003
@@ -15,7 +15,7 @@
 
 
 <browser:menuItem
-  menu="add_component"
+  menu="add_service"
   for="zope.app.interfaces.container.IAdding"
   action="WorkflowService"
   title='Workflow Service'
@@ -23,49 +23,40 @@
   />
 
 
-<!-- Workflow Process Definition **Example**
-     This is only a generic placeholder for
-     future Process Definition implementations
-
-<browser:menuItem
-  menu="add_component"
-  for="zope.app.interfaces.container.IAdding"
-  action="ProcessDefinition"
-  title='Process Definition'
-  description="A workflow process definition" />
 
+<!-- ProcessDefinition Configuration -->
 
 <browser:page
   for="zope.app.interfaces.workflow.IProcessDefinition"
-  name="index.html"
-  template="definition_index.pt"
-  class="zope.app.browser.workflow.definition.ProcessDefinitionView"
-  permission="zope.workflow.ManageProcessDefinitions"  
+  name="useConfiguration.html"
+  template="useprocessdefinitionconfig.pt"
+  class=".definition.UseConfiguration"
+  permission="zope.workflow.ManageProcessDefinitions"
+  menu="zmi_views" title="Configurations"
   />
 
--->
 
-
-<!-- ProcessDefinition Configuration -->
-
-<browser:view
-  for="zope.app.interfaces.container.IAdding"
-  name="ProcessDefinitionConfiguration"
-  class="zope.app.browser.workflow.definition.AddProcessDefinitionConfiguration"
-  permission="zope.workflow.ManageProcessDefinitions">
+<browser:addform
+  for="zope.app.interfaces.workflow.IProcessDefinition"
+  name="addConfiguration.html"
+  schema="zope.app.interfaces.workflow.IProcessDefinitionConfiguration"
+  class=".definition.AddProcessDefinitionConfiguration"
+  permission="zope.workflow.ManageProcessDefinitions"
+  content_factory="zope.app.workflow.service.ProcessDefinitionConfiguration"
+  arguments="name componentPath"
+  set_after_add="status"
+  fields="name componentPath permission status"
+  />
  
-  <browser:page name="add.html" template="addprocessdefinitionconfig.pt" />
-  <browser:page name="finish.html" attribute="action" />
-</browser:view>
-
-
-<browser:menuItem
-  menu="add_configuration"
-  for="zope.app.interfaces.container.IAdding"
-  action="ProcessDefinitionConfiguration"
-  title="Process Definition"
-  description="Workflow Process Definition"
+<browser:editform
+  name="index.html"
+  menu="zmi_views" title="Edit"
+  schema="zope.app.interfaces.workflow.IProcessDefinitionConfiguration"
+  label="ProcessDefinition Configuration"
+  permission="zope.workflow.ManageProcessDefinitions"
+  fields="name componentPath permission status"
   />
+
 
 
 <!-- ProcessDefinitionElementContainer -->


=== Packages3/workflow/browser/definition.py 1.2 => 1.3 ===
--- Packages3/workflow/browser/definition.py:1.2	Wed Feb  5 20:20:55 2003
+++ Packages3/workflow/browser/definition.py	Wed Mar 19 12:00:42 2003
@@ -17,36 +17,67 @@
 """
 __metaclass__ = type
  
-from zope.component import getServiceManager
+from zope.component import getAdapter, getView
 from zope.publisher.browser import BrowserView
-from zope.app.form.utility import setUpWidgets, getWidgetsDataForContent
+
+from zope.proxy.context import getWrapperContainer
+from zope.app.traversing import traverse, getPhysicalPathString
+from zope.app.form.widget import CustomWidget
+from zope.app.browser.services.field import ComponentPathDisplayWidget
+from zope.app.interfaces.services.configuration import IUseConfiguration
+from zope.app.interfaces.container import IZopeContainer
+
 from zope.app.interfaces.workflow import IProcessDefinitionConfiguration
 from zope.app.interfaces.workflow import IProcessDefinition
 from zope.app.workflow.service import ProcessDefinitionConfiguration
+
+
+class UseConfiguration(BrowserView):
+    """View for displaying the configurations for a process definition
+    """
+
+    def uses(self):
+        """Get a sequence of configuration summaries
+        """
+        component = self.context
+        useconfig = getAdapter(component, IUseConfiguration)
+        result = []
+        for path in useconfig.usages():
+            config = traverse(component, path)
+            url = getView(config, 'absolute_url', self.request)
+            result.append({'name': config.name,
+                           'path': path,
+                           'url': url(),
+                           'status': config.status,
+                           })
+        return result
+
+
  
 class AddProcessDefinitionConfiguration(BrowserView):
  
-    def __init__(self, *args):
-        super(AddProcessDefinitionConfiguration, self).__init__(*args)
-        setUpWidgets(self, IProcessDefinitionConfiguration)
- 
-    def components(self):
-        service = getServiceManager(self.context.context)
-        paths = [info['path']
-                 for info in service.queryComponent(type=IProcessDefinition)]
-        paths.sort()
-        return paths
- 
-    def action(self, definition_name, component_path=None):
-        if not definition_name:
-            raise ValueError('You must specify a ProcessDefinition name')
-        if not component_path:
-            raise ValueError('You must specify a component path')
-        cd = ProcessDefinitionConfiguration(definition_name, component_path)
-        cd = self.context.add(cd)
-        getWidgetsDataForContent(self, IProcessDefinitionConfiguration, content=cd)
-        self.request.response.redirect(self.context.nextURL())
 
+    componentPath = CustomWidget(ComponentPathDisplayWidget)
+
+    def beforeUpdateHook(self):
+        path = getPhysicalPathString(self.context)
+        self.request.form[self.componentPath.name] = path
+
+
+    def add(self, content):
+        # get the configuration manager for this folder
+        configure = traverse(getWrapperContainer(self.context), 'configure')
+        container = getAdapter(configure, IZopeContainer)
+
+        # Add the configuration
+        key = container.setObject("", content)
+
+        return container[key]
+
+    def nextURL(self):
+        return "@@useConfiguration.html"
+
+ 
 
 
 class ProcessDefinitionView(BrowserView):


=== Packages3/workflow/browser/definition_index.pt 1.1 => 1.2 ===
--- Packages3/workflow/browser/definition_index.pt:1.1	Wed Feb  5 20:09:30 2003
+++ Packages3/workflow/browser/definition_index.pt	Wed Mar 19 12:00:42 2003
@@ -1,14 +1,14 @@
-<html metal:use-macro="views/standard_macros/page">
-<head>
-  <title>ProcessDefinition</title>
-</head>
-<body>
- 
-  <div metal:fill-slot="body">
-
-  <p>ProcessDefinition: <tal:block tal:replace="view/getName" /></p>
- 
-  </div>
- 
-</body>
+<html metal:use-macro="views/standard_macros/page">
+<head>
+  <title>ProcessDefinition</title>
+</head>
+<body>
+ 
+  <div metal:fill-slot="body">
+
+  <p>ProcessDefinition: <tal:block tal:replace="view/getName" /></p>
+ 
+  </div>
+ 
+</body>
 </html>


=== Packages3/workflow/browser/workflows.pt 1.1 => 1.2 ===
--- Packages3/workflow/browser/workflows.pt:1.1	Wed Feb  5 20:09:30 2003
+++ Packages3/workflow/browser/workflows.pt	Wed Mar 19 12:00:42 2003
@@ -1,33 +1,33 @@
-<html metal:use-macro="views/standard_macros/page">
-<body metal:fill-slot="body">
-<div metal:use-macro="view/indexMacros/macros/body">
- 
-  <h2 metal:fill-slot="heading">ProcessDefinitions configured in this workflow service.</h2>
- 
-  <p metal:fill-slot="empty_text">No ProcessDefinitions have been configured</p>
- 
-  <div metal:fill-slot="extra_top">
- 
-    <p>For each ProcessDefinition, the ProcessDefinition name is given and all of the
-       components registered to provide the ProcessDefinition are shown.  You
-       may select the component to provide the ProcessDefinition or disable the
-       ProcessDefinition.
-    </p>
- 
-    <p>Select a ProcessDefinition name or a component name to visit the ProcessDefinition
-       or component.
-    </p>
- 
-  </div>
- 
-  <p metal:fill-slot="help_text">To configure a ProcessDefinition, add a ProcessDefinition
-     component to a <em>package</em> in <a
-     href="../../../Packages">Packages</a> or to the <a
-     href="../../../Packages/default">default package</a>. After the component
-     is added, add a ProcessDefinition configuration that configures the component to
-     provide a ProcessDefinition.
-  </p>
- 
-</div>
-</body>
+<html metal:use-macro="views/standard_macros/page">
+<body metal:fill-slot="body">
+<div metal:use-macro="view/indexMacros/macros/body">
+ 
+  <h2 metal:fill-slot="heading">ProcessDefinitions configured in this workflow service.</h2>
+ 
+  <p metal:fill-slot="empty_text">No ProcessDefinitions have been configured</p>
+ 
+  <div metal:fill-slot="extra_top">
+ 
+    <p>For each ProcessDefinition, the ProcessDefinition name is given and all of the
+       components registered to provide the ProcessDefinition are shown.  You
+       may select the component to provide the ProcessDefinition or disable the
+       ProcessDefinition.
+    </p>
+ 
+    <p>Select a ProcessDefinition name or a component name to visit the ProcessDefinition
+       or component.
+    </p>
+ 
+  </div>
+ 
+  <p metal:fill-slot="help_text">To configure a ProcessDefinition, add a ProcessDefinition
+     component to a <em>package</em> in <a
+     href="../../../Packages">Packages</a> or to the <a
+     href="../../../Packages/default">default package</a>. After the component
+     is added, add a ProcessDefinition configuration that configures the component to
+     provide a ProcessDefinition.
+  </p>
+ 
+</div>
+</body>
 </html>

=== Removed File Packages3/workflow/browser/addprocessdefinitionconfig.pt ===