[Zope-CVS] CVS: Packages3/workflow/browser - instance.py:1.1 instance_index.pt:1.1 instancecontainer_index.pt:1.1 instancecontainer_main.pt:1.1 configure.zcml:1.5
Ulrich Eck
ueck@net-labs.de
Fri, 7 Feb 2003 16:51:22 -0500
Update of /cvs-repository/Packages3/workflow/browser
In directory cvs.zope.org:/tmp/cvs-serv15434/browser
Modified Files:
configure.zcml
Added Files:
instance.py instance_index.pt instancecontainer_index.pt
instancecontainer_main.pt
Log Message:
First usable state of Stateful Workflow :)
- Implemented ProcessInstanceContainer/Adapter + Views
- Implemented Dummy ContentWorkflowsUtility
- updated Readme
- fixed some bugs
--> read the README for a small tutorial of what works
=== Added File Packages3/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 2003/02/07 21:50:51 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()
info['data'] = self._getProcessInstanceData(pi.data)
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 Packages3/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 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 Packages3/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>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 Packages3/workflow/browser/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> </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>
=== Packages3/workflow/browser/configure.zcml 1.4 => 1.5 ===
--- Packages3/workflow/browser/configure.zcml:1.4 Fri Feb 7 10:29:25 2003
+++ Packages3/workflow/browser/configure.zcml Fri Feb 7 16:50:51 2003
@@ -23,7 +23,7 @@
/>
-<!-- Workflow Process Definition
+<!-- Workflow Process Definition **Example**
This is only a generic placeholder for
future Process Definition implementations
@@ -91,6 +91,27 @@
title="Contents"
action="contents.html"
/>
+
+
+<!-- ProcessInstanceContainerAdaptable -->
+<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" />