[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/browser -
__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 workflows.py:1.1
Philipp von Weitershausen
philikon at philikon.de
Fri Feb 27 11:50:40 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/workflow/browser
In directory cvs.zope.org:/tmp/cvs-serv22977/workflow/browser
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 workflows.py
Log Message:
Centralized the workflow interfaces and browser views in
zope.app.workflow.
=== Added File Zope3/src/zope/app/workflow/browser/__init__.py ===
# make this directory a package
=== Added File Zope3/src/zope/app/workflow/browser/configure.zcml ===
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser"
>
<!-- Workflow Service -->
<page
for="zope.app.workflow.interfaces.IWorkflowService"
name="index.html"
template="workflows.pt"
class=".workflows.WorkflowsRegistryView"
permission="zope.ManageServices"
menu="zmi_views" title="Processes" />
<addMenuItem
class="zope.app.workflow.service.WorkflowService"
title="Workflow Service"
description="A workflow service"
permission="zope.ManageServices" />
<!-- ProcessDefinition Registration -->
<page
for="zope.app.workflow.interfaces.IProcessDefinition"
name="useRegistration.html"
template="useprocessdefinitionconfig.pt"
class=".definition.Registered"
permission="zope.workflow.ManageProcessDefinitions"
menu="zmi_views" title="Registrations" />
<addform
for="zope.app.workflow.interfaces.IProcessDefinition"
name="addRegistration.html"
schema="zope.app.workflow.interfaces.IProcessDefinitionRegistration"
class="zope.app.browser.services.registration.AddComponentRegistration"
permission="zope.workflow.ManageProcessDefinitions"
content_factory="zope.app.workflow.service.ProcessDefinitionRegistration"
arguments="name componentPath"
set_after_add="status"
fields="name componentPath permission status"
usage="addingdialog" />
<editform
name="index.html"
menu="zmi_views" title="Edit"
schema="zope.app.workflow.interfaces.IProcessDefinitionRegistration"
label="ProcessDefinition Registration"
permission="zope.workflow.ManageProcessDefinitions"
fields="name componentPath permission status" />
<page
for="zope.app.workflow.interfaces.IProcessDefinition"
name="importexport.html"
template="importexport_index.pt"
class=".definition.ImportExportView"
permission="zope.workflow.ManageProcessDefinitions"
menu="zmi_views" title="Import/Export" />
<pages
for="zope.app.workflow.interfaces.IProcessDefinition"
permission="zope.workflow.ManageProcessDefinitions"
class=".definition.ImportExportView">
<page name="import.html" attribute="importDefinition" />
<page name="export.html" attribute="exportDefinition" />
</pages>
<!-- ProcessDefinitionElementContainer -->
<page
for="zope.app.workflow.interfaces.IProcessDefinitionElementContainer"
permission="zope.workflow.ManageProcessDefinitions"
class="zope.app.browser.container.contents.Contents"
name="contents.html"
attribute="contents"
menu="zmi_views" title="Contents" />
<defaultView
for="zope.app.workflow.interfaces.IProcessDefinitionElementContainer"
name="contents.html" />
<!-- ProcessInstanceContainerAdaptable
XXX Commented Out .. is just a demo
<pages
for="zope.app.workflow.interfaces.IProcessInstanceContainerAdaptable"
permission="zope.workflow.UseProcessInstances"
class="zope.app.workflow.browser.instance.InstanceContainerView">
<page name="processinstances.html" attribute="contents"
menu="zmi_views" title="ProcessInstances" />
<page name="removeObjects.html" attribute="removeObjects" />
<page name="processinstance.html" attribute="instanceindex" />
</pages>
-->
<zope:include package=".stateful" />
</zope:configure>
=== Added File Zope3/src/zope/app/workflow/browser/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 registration adding view
$Id: definition.py,v 1.1 2004/02/27 16:50:37 philikon Exp $
"""
__metaclass__ = type
from zope.component import getAdapter, getView, getUtility
from zope.app.traversing import traverse
from zope.app.interfaces.services.registration import IRegistered
from zope.app.workflow.interfaces import IProcessDefinitionImportExport
class Registered:
"""View for displaying the registrations for a process definition"""
def uses(self):
"""Get a sequence of registration summaries"""
component = self.context
useconfig = getAdapter(component, IRegistered)
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:
def getName(self):
return """I'm a dummy ProcessInstance"""
class ImportExportView:
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/workflow/browser/definition_index.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
<title metal:fill-slot="title" i18n:translate="">Process Definition</title>
</head>
<body>
<div metal:fill-slot="body">
<p i18n:translate="">
Process Definition:
<tal:block tal:replace="view/getName" i18n:name="pd_name"/>
</p>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/importexport_index.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body">
<br />
<p tal:define="success request/success | nothing"
tal:condition="success"
i18n:translate="">
Import was successfull!
</p>
<p i18n:translate="">Import / Export Process Definitions:</p>
<span i18n:translate="">Import:</span>
<form action="@@import.html" method="post" encoding="multipart/form-data">
<textarea cols="50" rows="10" name="definition"></textarea>
<br />
<input type="submit" value="Import"
i18n:attributes="value import-button" />
</form>
<p i18n:translate="">
Export: <a href="@@export.html">save as file</a>
</p>
<pre tal:content="view/doExport"/>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/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 2004/02/27 16:50:37 philikon Exp $
"""
from zope.component import getAdapter
from zope.schema import getFieldNames
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.workflow.interfaces import IProcessInstanceContainerAdaptable
from zope.app.workflow.interfaces import IProcessInstanceContainer
from zope.app.workflow.interfaces.stateful import IStatefulProcessInstance
__metaclass__ = type
class InstanceContainerView:
__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 = []
for interface in providedBy(data):
names.append(getFieldNames(interface))
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/workflow/browser/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 define="pi_name request/pi_name;
info python:view.getProcessInstanceInfo(pi_name)">
<p i18n:translate="">
Status:
<tal:block tal:replace="info/status" i18n:name="status"/>
</p>
<div i18n:translate="">Outgoing Transitions:</div>
<br />
<tal:block repeat="name info/outgoing_transitions"
condition="info/outgoing_transitions | nothing">
<span 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 i18n:translate="">Key</th>
<th i18n:translate="">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>
</tal:block>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/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 i18n:translate="">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>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/instancecontainer_main.pt ===
<html metal:use-macro="views/standard_macros/page">
<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> </th>
<th i18n:translate="">Name</th>
</tr>
</thead>
<tbody>
<tal:block 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>
</tal:block>
</tbody>
</table>
<br />
<input type="submit" name="@@removeObjects.html:method" value="Delete"
i18n:attributes="value delete-button" />
</form>
</div>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/useprocessdefinitionconfig.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body">
<p i18n:translate="">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" i18n:translate="">
Add a configuration for this process definition
</a></p>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/workflows.pt ===
<html metal:use-macro="views/standard_macros/page">
<body>
<div metal:fill-slot="body">
<div metal:use-macro="view/indexMacros/macros/body">
<h2 metal:fill-slot="heading" i18n:translate="">
ProcessDefinitions configured in this workflow service.
</h2>
<p metal:fill-slot="empty_text" i18n:translate="">
No ProcessDefinitions have been configured
</p>
<div metal:fill-slot="extra_top">
<p i18n:translate="">
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 i18n:translate="">
Select a ProcessDefinition name or a component name to visit the
ProcessDefinition or component.</p>
</div>
<p metal:fill-slot="help_text" i18n:translate="">
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>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/workflow/browser/workflows.py ===
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""Workflow View Classes
$Id: workflows.py,v 1.1 2004/02/27 16:50:37 philikon Exp $
"""
from zope.app.browser.services.registration import \
NameComponentRegistryView, NameRegistryView
from zope.app.traversing import traverse, getParent
from zope.component import getView
class WorkflowsRegistryView(NameComponentRegistryView):
def _getItem(self, name, view, cfg):
item_dict = NameRegistryView._getItem(self, name, view, cfg)
if cfg is not None:
ob = traverse(getParent(getParent(cfg)), cfg.componentPath)
url = str(getView(ob, 'absolute_url', self.request))
else:
url = None
item_dict['url'] = url
return item_dict
More information about the Zope3-Checkins
mailing list