[Zope3-checkins] CVS: Zope3/src/zope/app/browser/workflow - __init__.py:1.1 configure.zcml:1.1 definition.py:1.1 definition_index.pt:1.1 importexport_index.pt:1.1 instance.py:1.1 instance_index.pt:1.1 instancecontainer_index.pt:1.1 instancecontainer_main.pt:1.1 useprocessdefinitionconfig.pt:1.1 workflows.pt:1.1

Ulrich Eck ueck@net-labs.de
Thu, 8 May 2003 13:27:18 -0400


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

Added Files:
	__init__.py configure.zcml definition.py definition_index.pt 
	importexport_index.pt instance.py instance_index.pt 
	instancecontainer_index.pt instancecontainer_main.pt 
	useprocessdefinitionconfig.pt workflows.pt 
Log Message:
Finally got it into Zope3:

Workflow has arrived!

this is a merge of the workflow package that was seperatly developed
at /Packages3/workflow.

please to a 

cvs update -dPA 

to ensure that old files/directories are deleted, otherwise you'll 
probably encounter errors when trying to run zope3

if you have problems .. send me an email ueck <at> net-labs.de

Ulrich


=== Added File Zope3/src/zope/app/browser/workflow/__init__.py ===


=== Added File Zope3/src/zope/app/browser/workflow/configure.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:browser='http://namespaces.zope.org/browser'>


<!-- Workflow Service -->
<browser:page
  for="zope.app.interfaces.workflow.IWorkflowService"
  name="index.html"
  template="workflows.pt"
  class="zope.app.browser.services.configuration.NameComponentConfigurableView"
  permission="zope.ManageServices"  
  />



<browser:menuItem
  menu="add_service"
  for="zope.app.interfaces.container.IAdding"
  action="WorkflowService"
  title='Workflow Service'
  description="A workflow service" 
  />



<!-- ProcessDefinition Configuration -->

<browser:page
  for="zope.app.interfaces.workflow.IProcessDefinition"
  name="useConfiguration.html"
  template="useprocessdefinitionconfig.pt"
  class=".definition.UseConfiguration"
  permission="zope.workflow.ManageProcessDefinitions"
  menu="zmi_views" title="Configurations"
  />


<browser:addform
  for="zope.app.interfaces.workflow.IProcessDefinition"
  name="addConfiguration.html"
  schema="zope.app.interfaces.workflow.IProcessDefinitionConfiguration"
  class="zope.app.browser.services.configuration.AddComponentConfiguration"
  permission="zope.workflow.ManageProcessDefinitions"
  content_factory="zope.app.workflow.service.ProcessDefinitionConfiguration"
  arguments="name componentPath"
  set_after_add="status"
  fields="name componentPath permission status"
  />
 
<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"
  />


<browser:page
  for="zope.app.interfaces.workflow.IProcessDefinition"
  name="importexport.html"
  template="importexport_index.pt"
  class=".definition.ImportExportView"
  permission="zope.workflow.ManageProcessDefinitions"
  menu="zmi_views" title="Import/Export"
  />

<browser:pages
     for="zope.app.interfaces.workflow.IProcessDefinition"
     permission="zope.workflow.ManageProcessDefinitions"
     class=".definition.ImportExportView">
     
    <browser:page name="import.html" attribute="importDefinition" />
    <browser:page name="export.html" attribute="exportDefinition" />
</browser:pages>


<!-- ProcessDefinitionElementContainer -->

<browser:defaultView
  for="zope.app.interfaces.workflow.IProcessDefinitionElementContainer"
  name="contents.html"
  />  

<browser:pages
     for="zope.app.interfaces.workflow.IProcessDefinitionElementContainer"
     permission="zope.workflow.ManageProcessDefinitions"
     class="zope.app.browser.container.contents.Contents">
     >

    <browser:page name="contents.html" attribute="contents" />
    <browser:page name="removeObjects.html" attribute="removeObjects" />
    <browser:page name="cutObjects.html" attribute="cutObjects" />
    <browser:page name="copyObjects.html" attribute="copyObjects" />
    <browser:page name="pasteObjects.html" attribute="pasteObjects" />
    <browser:page name="renameObjects.html" attribute="renameObjects" />
    <browser:page name="rename.html" attribute="rename" />

  </browser:pages>


<browser:menuItem
  for="zope.app.interfaces.workflow.IProcessDefinitionElementContainer"
  menu="zmi_views"
  title="Contents"
  action="contents.html"
  />

<adapter factory="zope.app.container.zopecontainer.ZopeContainerAdapter"
  provides="zope.app.interfaces.container.IZopeContainer"
  for="zope.app.interfaces.workflow.IProcessDefinitionElementContainer"
  />


<!-- ProcessInstanceContainerAdaptable 
     XXX Commented Out .. is just a demo
<browser:pages
  for="zope.app.interfaces.workflow.IProcessInstanceContainerAdaptable"
  permission="zope.workflow.UseProcessInstances"
  class="zope.app.browser.workflow.instance.InstanceContainerView">

  <browser:page name="processinstances.html" attribute="contents" />
  <browser:page name="removeObjects.html" attribute="removeObjects" />
  <browser:page name="processinstance.html" attribute="instanceindex" />

</browser:pages>

<browser:menuItem
  for="zope.app.interfaces.workflow.IProcessInstanceContainerAdaptable"
  menu="zmi_views"
  title="ProcessInstances"
  action="processinstances.html"
  />
-->


<include package=".stateful" />

</zopeConfigure>


=== Added File Zope3/src/zope/app/browser/workflow/definition.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""ProcessDefinition configuration adding view
 
$Id: definition.py,v 1.1 2003/05/08 17:27:17 jack-e Exp $
"""
__metaclass__ = type
 
from zope.component import getAdapter, getView, getUtility
from zope.publisher.browser import BrowserView
from zope.app.traversing import traverse
from zope.app.interfaces.services.configuration import IUseConfiguration
from zope.app.interfaces.workflow import IProcessDefinitionImportExport



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 ProcessDefinitionView(BrowserView):
 
    def getName(self):
        return """I'm a dummy ProcessInstance"""


class ImportExportView(BrowserView):

    def doExport(self):
        return self._getUtil().exportProcessDefinition(self.context,
                                                       self.context)

    def doImport(self, data):
        return self._getUtil().importProcessDefinition(self.context,
                                                       data)
    def _getUtil(self):
        return getUtility(self.context, IProcessDefinitionImportExport)

    def importDefinition(self):
        xml = self.request.get('definition')
        if xml:
            self.doImport(xml)
        self.request.response.redirect('@@importexport.html?success=1')

    def exportDefinition(self):
        return self.doExport()


=== Added File Zope3/src/zope/app/browser/workflow/definition_index.pt ===
<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>

=== Added File Zope3/src/zope/app/browser/workflow/importexport_index.pt ===
  <html metal:use-macro="context/@@standard_macros/page">
    <body>
      <div metal:fill-slot="body">
        <span tal:define="success request/success | nothing"
          tal:condition="success"><br/>Import was successfull!<br/></span>

        <p>Import / Export ProcessDefinitions:</p>
        Import:
        <form action="@@import.html" method="post" encoding="multipart/form-data">
          <textarea cols="50" rows="10" name="definition"></textarea><br/>
            <input type="submit" value="do import"/>
        </form>
        <p></p>
        Export: <a href="@@export.html">save as file</a><br/>
          <pre tal:content="view/doExport"/>
      </div>
    </body>
  </html>
  

=== Added File Zope3/src/zope/app/browser/workflow/instance.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""ProcessInstance views
 
$Id: instance.py,v 1.1 2003/05/08 17:27:17 jack-e Exp $
"""
__metaclass__ = type

from zope.schema import getFieldNames
from zope.component import queryView, queryAdapter,  getAdapter
from zope.publisher.browser import BrowserView
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

from zope.app.interfaces.workflow import IProcessInstanceContainerAdaptable
from zope.app.interfaces.workflow import IProcessInstanceContainer
from zope.app.interfaces.workflow.stateful import IStatefulProcessInstance

 
class InstanceContainerView(BrowserView):

    __used_for__ = IProcessInstanceContainerAdaptable


    def _extractContentInfo(self, item):
        id, obj = item
        info = {}
        info['id'] = id
        info['object'] = obj

        # XXX need to urlencode the id in this case !!!
        info['url'] = "processinstance.html?pi_name=%s" % id
 
        return info
 
 
    def removeObjects(self, ids):
        """Remove objects specified in a list of object ids"""
        container = getAdapter(self.context, IProcessInstanceContainer)
        for id in ids:
            container.__delitem__(id)
 
        self.request.response.redirect('@@processinstances.html')
 
    def listContentInfo(self):
        return map(self._extractContentInfo,
                   getAdapter(self.context, IProcessInstanceContainer).items())
 
    contents = ViewPageTemplateFile('instancecontainer_main.pt')
    contentsMacros = contents
 
    _index = ViewPageTemplateFile('instancecontainer_index.pt')
 
    def index(self):
        if 'index.html' in self.context:
            self.request.response.redirect('index.html')
            return ''
 
        return self._index()    


    # ProcessInstance Details
    # XXX This is temporary till we find a better name to use
    #     objects that are stored in annotations
    #     Steve suggested a ++annotations++<key> Namespace for that.
    #     we really want to traverse to the instance and display a view

    def _getProcessInstanceData(self, data):
        names = getFieldNames(data.__implements__)
        return dict([(name, getattr(data, name, None),) for name in names ])

    def getProcessInstanceInfo(self, pi_name):
        info = {}
        pi = getAdapter(self.context, IProcessInstanceContainer)[pi_name]
        info['status'] = pi.status
        
        # temporary
        if IStatefulProcessInstance.isImplementedBy(pi):
            info['outgoing_transitions'] = pi.getOutgoingTransitions()

        if pi.data is not None:
            info['data'] = self._getProcessInstanceData(pi.data)
        else:
            info['data'] = None
            
        return info

    def _fireTransition(self, pi_name, id):
        pi = getAdapter(self.context, IProcessInstanceContainer)[pi_name]
        pi.fireTransition(id)


    _instanceindex = ViewPageTemplateFile('instance_index.pt')

    def instanceindex(self):
        """ProcessInstance detail view."""
        request = self.request
        pi_name = request.get('pi_name')
        if pi_name is None:
            request.response.redirect('index.html')
            return ''

        if request.has_key('fire_transition'):
            self._fireTransition(pi_name, request['fire_transition'])
        
        return self._instanceindex()


=== Added File Zope3/src/zope/app/browser/workflow/instance_index.pt ===
  <html metal:use-macro="views/standard_macros/page">
    <head>
      <style metal:fill-slot="headers" type="text/css">
        <!--
        .ContentTitle {
        text-align: left;
        }
        -->
      </style>
    </head>
    <body>
      <div metal:fill-slot="body">
        <tal:block tal:define="pi_name request/pi_name;
          info python:view.getProcessInstanceInfo(pi_name)">

          <p>Status: <tal:block tal:replace="info/status" /></p>

          Outgoing Transitions:<br />
            <tal:block tal:repeat="name info/outgoing_transitions"
          tal:condition="info/outgoing_transitions | nothing">
          <tal:block tal:replace="name" /> 
            <a tal:attributes="href string:?pi_name=${pi_name}&fire_transition=${name}">fire</a><br />
          </tal:block>
          
          <table  id="sortable" class="listing" summary="ProcessInstance Data"
                 cellpadding="2" cellspacing="0" >
            
            <thead> 
              <tr>
                <th>Key</th>
                <th>Value</th>
              </tr>
            </thead>
            
            <tbody tal:define="data info/data | nothing"
              tal:condition="info/data">
  
              <tr tal:repeat="key python:data.keys()">
                <td class="ContentTitle" tal:content="key" />
        <td tal:content="python:data.get(key) or default">No Value</td>
              </tr>
              
            </tbody>
            
          </table>
          <br />
        </tal:block>
      </div>
    </body>
  </html>






=== Added File Zope3/src/zope/app/browser/workflow/instancecontainer_index.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css">
<!--

.ContentTitle {
    text-align: left;
}
-->
</style>
</head>
<body>
<div metal:fill-slot="body">

  <table  id="sortable" class="listing" summary="ProcessInstance listing"
             cellpadding="2" cellspacing="0" >

    <thead> 
      <tr>
        <th>Name</th>
      </tr>
    </thead>
  
    <tbody>
  
      <tr tal:repeat="info view/listContentInfo">
  
	<td class="ContentTitle">
	  <a href="subfolder_id"
	     tal:attributes="href info/url"
             tal:content="info/id"
	  >ID here</a>
	</td>

      </tr>
  
    </tbody>
  
  </table>
  <br />

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






=== Added File Zope3/src/zope/app/browser/workflow/instancecontainer_main.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<style metal:fill-slot="headers" type="text/css">
</style>
</head>
<body>
<div metal:fill-slot="body">
<div metal:define-macro="contents">

  <form name="containerContentsForm" method="get" action="." 
        tal:define="container_contents view/listContentInfo"
        tal:condition="container_contents"
        >

      <table id="sortable" class="listing" summary="ProcessInstance listing"
             cellpadding="2" cellspacing="0" 
             metal:define-macro="contents_table"
             >
    
        <thead> 
          <tr>
            <th>&nbsp;</th>
            <th>Name</th>
          </tr>
        </thead>

        <tbody>

        <metal:block tal:repeat="item container_contents">
          <tr tal:define="oddrow repeat/item/odd; url item/url"
              tal:attributes="class python:oddrow and 'even' or 'odd'" > 
            <td>
              <input type="checkbox" class="noborder" name="ids:list" id="#"
                     value="#"
                     tal:attributes="value item/id;
                                     id python: 'cb_'+item['id'];
                                     checked request/ids_checked|nothing;"/>
            </td>
            <td> 
              <a href="#" 
                 tal:attributes="href 
                                 string:${url}"
                 tal:content="item/id"
                 >foo</a> 
            </td>
          </tr>
        </metal:block>
        </tbody> 
      </table>
      <br />

      <input type="submit" name="@@removeObjects.html:method" value="Delete"
             tal:attributes="value string:menu_delete_button"
             i18n:attributes="value" /> 

  </form>

</div>

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






=== Added File Zope3/src/zope/app/browser/workflow/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>


=== Added File Zope3/src/zope/app/browser/workflow/workflows.pt ===
<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>