[Zope3-checkins] CVS: Packages3/workflow/browser/stateful - content_filter.py:1.1 instance_manage.pt:1.1 published_content.pt:1.1 configure.zcml:1.7 do_transitions.pt:NONE view.py:NONE

Ulrich Eck ueck@net-labs.de
Wed, 26 Mar 2003 14:41:03 -0500


Update of /cvs-repository/Packages3/workflow/browser/stateful
In directory cvs.zope.org:/tmp/cvs-serv29708/browser/stateful

Modified Files:
	configure.zcml 
Added Files:
	content_filter.py instance_manage.pt published_content.pt 
Removed Files:
	do_transitions.pt view.py 
Log Message:
helper view vor filtering folder_contents by WorkflowState


=== Added File Packages3/workflow/browser/stateful/content_filter.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.
#
##############################################################################
"""filtering view for ProcessInstances of a stateful workflow
 
$Id: content_filter.py,v 1.1 2003/03/26 19:41:02 jack-e Exp $
"""
__metaclass__ = type

from zope.component import getAdapter, queryAdapter, getService
from zope.app.services.servicenames import Workflows
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
from zope.app.browser.container.contents import Contents
 
class FilterList(Contents):

    __used_for__ = IProcessInstanceContainerAdaptable


    def filterByState(self, objList, state, workflow='default'):
        """Filter a list of objects according to given workflow and state

        objList  ... list of objects
        state    ... name of a state (of the given workflow) in which the result
                      objects must be
        workflow ... name of a workflow to which result objects must be attached
        """
        res = []

        for obj in objList:
            adapter = queryAdapter(obj['object'], IProcessInstanceContainer)
            if adapter:
                for item in adapter.values():
                    if item.processDefinitionName != workflow:
                        continue
                    if item.status == state:
                        res.append(obj)
                        break

        return res


    published_content = ViewPageTemplateFile('published_content.pt')

    def listPublishedItems(self):
        return self.filterByState(self.listContentInfo(), 'published')



=== Added File Packages3/workflow/browser/stateful/instance_manage.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">
          <div metal:define-macro="contents_selectWorkflow"
               tal:define="workflow request/workflow | nothing">
            <div tal:condition="not:workflow" tal:omit-tag="">
              <form name="containerContentsForm" method="get" action="@@workflows.html" 
                    tal:define="container_contents view/listContentInfo"
                    tal:condition="container_contents">
                Workflow: 
                <select name="workflow" size="1">
                  <option tal:repeat="workflow container_contents" 
                          tal:attributes="value workflow/id"
                          tal:content="workflow/name"></option>
                </select>
                <input type="submit" value="choose" />
              </form>
            </div>
            <div tal:condition="workflow" tal:omit-tag="">
              Workflow: <div tal:replace="view/getWorkflowTitle"></div>
            </div>
          </div>
          <div metal:define-macro="contents_changeState">
          </div>
          
        </div>
        <br/>
        <div metal:define-macro="contents_transitions"
             tal:define="info view/getTransitions">
            Current Status: <div tal:replace="info/status"/>
          <br/>
            Possible State Changes:
            <form action="@@fireTransition.html" method="get">
            <input type="hidden" name="workflow" tal:attributes="value request/workflow | nothing">
              <div tal:repeat="trans info/transitions" 
                   tal:condition="info/transitions | nothing"
                   tal:omit-tag="">
                <input type="radio"
                       name="selTransition"
                       tal:attributes="value trans/name"/> <span tal:replace="trans/title"/><br/>
              </div>
              <input type="submit" value="do it">
              </form>
        </div>
      </div>
    </body>
  </html>






=== Added File Packages3/workflow/browser/stateful/published_content.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 tal:repeat="obj view/listPublishedItems"
             tal:omit-tag="">
          <div tal:content="obj/url"/><br/>
          </div>
        </div>
    </body>
  </html>






=== Packages3/workflow/browser/stateful/configure.zcml 1.6 => 1.7 ===
--- Packages3/workflow/browser/stateful/configure.zcml:1.6	Wed Mar 26 14:24:05 2003
+++ Packages3/workflow/browser/stateful/configure.zcml	Wed Mar 26 14:41:02 2003
@@ -171,4 +171,14 @@
   />
 
 
+<browser:pages
+  for="zope.app.interfaces.container.IContentContainer"
+  permission="zope.View"
+  class="zope.app.browser.workflow.stateful.content_filter.FilterList">
+
+  <browser:page name="published_content.html" attribute="published_content" />
+</browser:pages>
+
+
+
 </zopeConfigure>

=== Removed File Packages3/workflow/browser/stateful/do_transitions.pt ===

=== Removed File Packages3/workflow/browser/stateful/view.py ===