[Zope3-checkins] CVS: Packages3/workflow/browser/stateful - configure.zcml:1.6 instance.py:1.2
Ulrich Eck
ueck@net-labs.de
Wed, 26 Mar 2003 14:24:36 -0500
Update of /cvs-repository/Packages3/workflow/browser/stateful
In directory cvs.zope.org:/tmp/cvs-serv27357/browser/stateful
Modified Files:
configure.zcml instance.py
Log Message:
added Workflows Tab to IProcessInstanceContainerAdaptable's
that is a Management View vor StatefulProcessInstances
=== Packages3/workflow/browser/stateful/configure.zcml 1.5 => 1.6 ===
--- Packages3/workflow/browser/stateful/configure.zcml:1.5 Wed Mar 26 12:43:37 2003
+++ Packages3/workflow/browser/stateful/configure.zcml Wed Mar 26 14:24:05 2003
@@ -153,4 +153,22 @@
+<!-- ProcessInstanceContainerAdaptable -->
+<browser:pages
+ for="zope.app.interfaces.workflow.IProcessInstanceContainerAdaptable"
+ permission="zope.workflow.UseProcessInstances"
+ class="zope.app.browser.workflow.stateful.instance.ManagementView">
+
+ <browser:page name="workflows.html" attribute="contents" />
+ <browser:page name="fireTransition.html" attribute="fireTransition" />
+</browser:pages>
+
+<browser:menuItem
+ for="zope.app.interfaces.workflow.IProcessInstanceContainerAdaptable"
+ menu="zmi_views"
+ title="Workflows"
+ action="workflows.html"
+ />
+
+
</zopeConfigure>
=== Packages3/workflow/browser/stateful/instance.py 1.1 => 1.2 ===
--- Packages3/workflow/browser/stateful/instance.py:1.1 Wed Mar 26 10:24:27 2003
+++ Packages3/workflow/browser/stateful/instance.py Wed Mar 26 14:24:05 2003
@@ -28,8 +28,9 @@
from zope.app.interfaces.workflow.stateful import IStatefulProcessInstance
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.proxy.introspection import removeAllProxies
+from zope.proxy.context import getWrapperData
-class StatefulInstanceContainerView(BrowserView):
+class ManagementView(BrowserView):
__used_for__ = IProcessInstanceContainerAdaptable
@@ -45,23 +46,30 @@
getAdapter(self.context, IProcessInstanceContainer).items())
def _getTitle(self, obj):
- return getAdapter(obj, IZopeDublinCore).Title()
+ return getAdapter(obj, IZopeDublinCore).Title() or getWrapperData(obj)['name']
- contents = ViewPageTemplateFile('do_transitions.pt')
+ contents = ViewPageTemplateFile('instance_manage.pt')
contentsMacros = contents
- def getWorkFlowTitle(self):
- return self._getTitle(
- self._getProcessDefinition(
- self._getSelWorkflow()))
+ def getWorkflowTitle(self):
+ pi = self._getSelWorkflow()
+ if pi is None:
+ return None
+
+ return self._getTitle(self._getProcessDefinition(pi))
def _getSelWorkflow(self):
- reqWorkflow = self.request.get('workFlow', u'')
- adapter = getAdapter(self.context, IProcessInstanceContainer)
+ reqWorkflow = self.request.get('workflow', u'')
+ pi_container = getAdapter(self.context, IProcessInstanceContainer)
if reqWorkflow is u'':
- pi = adapter[adapter.keys()[0]]
+ available_instances = pi_container.keys()
+ if len(available_instances) > 0:
+ pi = pi_container[available_instances[0]]
+ else:
+ pi = None
else:
- pi = adapter[reqWorkflow]
+ pi = pi_container[reqWorkflow]
+
return pi
@@ -73,24 +81,33 @@
def getTransitions(self):
info = {}
pi = self._getSelWorkflow()
- info['status'] = pi.status
- if IStatefulProcessInstance.isImplementedBy(pi):
- pd = self._getProcessDefinition(pi)
- # XXX do we really want to do that?
- clean_pd = removeAllProxies(pd)
- transition_names = pi.getOutgoingTransitions()
- trans_info = []
- print transition_names
- for name in transition_names:
- transition = clean_pd.getTransition(name)
- adapter = getAdapter(transition, IZopeDublinCore)
- trans_info.append({'name':name, 'title': adapter.Title()})
- info['transitions'] = trans_info
+ if pi is None:
+ return info
+
+
+ pd = self._getProcessDefinition(pi)
+ clean_pd = removeAllProxies(pd)
+
+ current_state = clean_pd.getState(pi.status)
+ adapter = getAdapter(current_state, IZopeDublinCore)
+ info['status'] = adapter.Title() or pi.status
+
+ transition_names = pi.getOutgoingTransitions()
+ trans_info = []
+ for name in transition_names:
+ transition = clean_pd.getTransition(name)
+ adapter = getAdapter(transition, IZopeDublinCore)
+ trans_info.append({'name':name,
+ 'title': adapter.Title() or name})
+ info['transitions'] = trans_info
return info
def fireTransition(self):
pi = self._getSelWorkflow()
+ if pi is None:
+ return
+
trans = self.request.get('selTransition', None)
- self.request.response.redirect('@@workflows.html?workFlow=%s' % pi.processDefinitionName)
+ self.request.response.redirect('@@workflows.html?workflow=%s' % pi.processDefinitionName)
if pi and trans:
pi.fireTransition(trans)