[Zope3-checkins] CVS: Zope3/src/zope/app/browser/workflow/stateful - configure.zcml:1.3 contentworkflow.py:1.3
Stephan Richter
srichter@cosmos.phy.tufts.edu
Tue, 29 Jul 2003 20:00:50 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/workflow/stateful
In directory cvs.zope.org:/tmp/cvs-serv20793/src/zope/app/browser/workflow/stateful
Modified Files:
configure.zcml contentworkflow.py
Log Message:
Workflow enhancements to make them more useful. (More to come)
- ContentWorkflowsUtility has been renamed to ContentWorkflowsManager
- Specific Process Definitions can now be mapped to interfaces (later
content types), so that a content type only receives the workflows that
were inteneded for it.
- Supplied a management screen for the above.
- Wrote a bunch of tests for ContentWorkflowsManager.
- Added a default screen to the Workflow Service, which lists all registered
process definitions.
=== Zope3/src/zope/app/browser/workflow/stateful/configure.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/workflow/stateful/configure.zcml:1.2 Mon Jun 23 12:41:50 2003
+++ Zope3/src/zope/app/browser/workflow/stateful/configure.zcml Tue Jul 29 20:00:16 2003
@@ -14,8 +14,9 @@
<browser:pages
- for="zope.app.interfaces.workflow.stateful.IStatefulProcessDefinition"
- class="zope.app.browser.workflow.stateful.definition.StatefulProcessDefinitionView"
+ for="zope.app.interfaces.workflow.stateful.IStatefulProcessDefinition"
+ class=
+ "zope.app.browser.workflow.stateful.definition.StatefulProcessDefinitionView"
permission="zope.ManageServices">
<browser:page name="index.html" template="definition_index.pt" />
@@ -34,8 +35,10 @@
for="zope.app.interfaces.workflow.stateful.IStatefulProcessDefinition"
menu="zmi_actions">
- <browser:menuItem title="Manage States" action="states/contents.html" />
- <browser:menuItem title="Manage Transitions" action="transitions/contents.html" />
+ <browser:menuItem
+ title="Manage States" action="states/contents.html" />
+ <browser:menuItem
+ title="Manage Transitions" action="transitions/contents.html" />
</browser:menuItems>
@@ -45,7 +48,6 @@
<browser:menu id="add_stateful_transitions" title="Transition Items" />
-
<!-- States Container -->
<browser:view
@@ -63,7 +65,6 @@
</browser:view>
-
<!-- State -->
<!-- nothing to edit yet
<browser:editform
@@ -87,10 +88,6 @@
/>
-
-
-
-
<!-- Transitions Container -->
<browser:view
@@ -99,8 +96,7 @@
menu="zmi_actions" title="Add"
class=".definition.TransitionsContainerAdding"
permission="zope.workflow.ManageProcessDefinitions"
- allowed_attributes="addingInfo"
- >
+ allowed_attributes="addingInfo">
<browser:page name="index.html" template="add.pt" />
<browser:page name="action.html" attribute="action" />
@@ -134,27 +130,30 @@
<browser:menuItem
menu="add_component"
for="zope.app.interfaces.container.IAdding"
- action="ContentWorkflowsUtility"
- title="Content Workflows Utility"
- description="An utility for creating/deleting workflow for content objects." />
+ action="ContentWorkflowsManager"
+ title="Content Workflows Manager"
+ description="An utility to manage content and workflow interaction."
+ />
<browser:pages
- for="zope.app.interfaces.workflow.stateful.IContentWorkflowsUtility"
- class="zope.app.browser.workflow.stateful.contentworkflow.ContentWorkflowsUtilityView"
+ for="zope.app.interfaces.workflow.stateful.IContentWorkflowsManager"
+ class=".contentworkflow.ContentWorkflowsManagerView"
permission="zope.ManageServices">
- <browser:page name="index.html" template="contentworkflow_index.pt" />
+ <browser:page name="index.html" template="contentworkflow_index.pt"
+ menu="zmi_views" title="Overview"/>
</browser:pages>
-<browser:menuItem
- menu="zmi_views"
- for="zope.app.interfaces.workflow.stateful.IContentWorkflowsUtility"
- action="index.html"
- title="Overview"
- description="ContentWorkflowsUtility Overview" />
+<browser:pages
+ for="zope.app.interfaces.workflow.stateful.IContentWorkflowsManager"
+ class=".contentworkflow.ManageContentProcessRegistry"
+ permission="zope.ManageServices">
+ <browser:page name="registry.html" template="contentworkflow_registry.pt"
+ menu="zmi_views" title="Content/Process Registry"/>
+</browser:pages>
<!-- ProcessInstanceContainerAdaptable -->
=== Zope3/src/zope/app/browser/workflow/stateful/contentworkflow.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/workflow/stateful/contentworkflow.py:1.2 Tue Jun 3 18:46:18 2003
+++ Zope3/src/zope/app/browser/workflow/stateful/contentworkflow.py Tue Jul 29 20:00:16 2003
@@ -17,12 +17,83 @@
"""
__metaclass__ = type
+from zope.app.browser.component.interfacewidget import \
+ interfaceToName, nameToInterface
+from zope.app.component.interfacefield import InterfaceField
+from zope.app.form.utility import setUpWidgets
+from zope.app.services.servicenames import Workflows
+from zope.component import getService
+from zope.interface import Interface
from zope.publisher.browser import BrowserView
+from zope.schema.vocabulary import VocabularyListField
+from zope.security.proxy import trustedRemoveSecurityProxy
-class ContentWorkflowsUtilityView(BrowserView):
+class ContentWorkflowsManagerView(BrowserView):
def getName(self):
return """I'm a ContentWorkflows Utility"""
+class IContentProcessMapping(Interface):
+ iface = InterfaceField(
+ title=u"Content Interface",
+ description=u"Specifies the interface that characterizes a particular "
+ u"content type. Select one interface at a time.",
+ required=True)
+
+ name = VocabularyListField(
+ title = u"Process Definition Name",
+ description = u"The name of the process that will be available for "
+ u"this content type. Feel free to select several at "
+ u"once.",
+ required = True,
+ vocabulary = "ProcessDefinitions")
+
+
+class ManageContentProcessRegistry(BrowserView):
+
+ def __init__(self, *args):
+ super(ManageContentProcessRegistry, self).__init__(*args)
+ setUpWidgets(self, IContentProcessMapping)
+ self.process_based = int(self.request.get('process_based', '1'))
+ print self.request
+
+ def getProcessInterfacesMapping(self):
+ mapping = []
+ wf = getService(self.context, Workflows)
+ for name in wf.getProcessDefinitionNames():
+ ifaces = self.context.getInterfacesForProcessName(name)
+ ifaces = map(interfaceToName, ifaces)
+ if ifaces:
+ mapping.append({'name': name, 'ifaces': ifaces})
+ return mapping
+
+ def getInterfaceProcessesMapping(self):
+ mapping = []
+ # Nothing bad here; we just read the registry data
+ registry = trustedRemoveSecurityProxy(self.context)._registry
+ for iface, names in registry.items():
+ mapping.append({'iface': interfaceToName(iface), 'names': names})
+ return mapping
+
+ def update(self):
+ status = ''
+ if 'ADD' in self.request:
+ for name in self.name_widget.getData():
+ self.context.register(self.iface_widget.getData(), name)
+ status = 'Mapping(s) added.'
+ elif 'REMOVE' in self.request:
+ mappings = self.request.get('mappings', [])
+ for entry in mappings:
+ split = entry.rfind(':')
+ name = entry[:split]
+ iface = nameToInterface(self.context, entry[split+1:])
+ self.context.unregister(iface, name)
+ status = 'Mapping(s) removed.'
+ elif 'SWITCH' in self.request:
+ self.request.response.setCookie('process_based',
+ self.request.get('other_view'))
+ self.process_based = int(self.request.get('other_view'))
+
+ return status