[Zope-CVS] CVS: Packages3/workflow - globalimportexport.py:1.1 meta.zcml:1.1 metaconfigure.py:1.1 README.txt:1.6 configure.zcml:1.7 notes.txt:1.2

Ulrich Eck ueck@net-labs.de
Wed, 26 Mar 2003 12:44:08 -0500


Update of /cvs-repository/Packages3/workflow
In directory cvs.zope.org:/tmp/cvs-serv13635

Modified Files:
	README.txt configure.zcml notes.txt 
Added Files:
	globalimportexport.py meta.zcml metaconfigure.py 
Log Message:
first round of checkin of our sprint work (some test are missing)


=== Added File Packages3/workflow/globalimportexport.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 Import Export Utility

$Id: globalimportexport.py,v 1.1 2003/03/26 17:43:36 jack-e Exp $
"""
__metaclass__ = type

from zope.interface.type import TypeRegistry
from zope.interface._flatten import _flatten
from zope.proxy.introspection import removeAllProxies
from zope.app.interfaces.workflow import IProcessDefinition
from zope.app.interfaces.workflow import IGlobalProcessDefinitionImportExport

class ImportExportUtility:

    __implements__ = IGlobalProcessDefinitionImportExport


    def __init__(self):
        self._importers = TypeRegistry()
        self._exporters = TypeRegistry()
        
    _clear = __init__

    # IProcessDefinitionImportExport
    
    def importProcessDefinition(self, data):
        """Import a Process Definition
        """
        for factory in self._importers.values():
            if factory is not None:
                imp = factory()
                if imp.canHandle(data):
                    return imp.doImport(data)
        raise ValueError, 'No Importer can handle that information'

    def exportProcessDefinition(self, process_definition):
        """Export a Process Definition
        """
        clean_pd = removeAllProxies(process_definition)
        interfaces = filter(lambda x: x.extends(IProcessDefinition),
                           _flatten(clean_pd.__implements__))
        for interface in interfaces:
            factory = self._exporters.get(interface)
            if factory is not None:
                return factory().doExport(clean_pd)
        raise TypeError, "object doesn't implement IProcessDefinition"


    # IGlobalProcessDefinitionImportExport

    def addImportHandler(self, interface, factory):
        """add Import Handler for ProcessDefinition
        """
        self._importers.setdefault(interface, factory)

    def addExportHandler(self, interface, factory):
        """add Export Handler for ProcessDefinition
        """
        self._exporters.setdefault(interface, factory)

    

globalImportExport = ImportExportUtility()


_clear = globalImportExport._clear

# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
from zope.testing.cleanup import addCleanUp
addCleanUp(_clear)
del addCleanUp


=== Added File Packages3/workflow/meta.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
  
  <directives namespace="http://namespaces.zope.org/workflow">

    <directive name="importHandler" 
               handler=".metaconfigure.importHandlerDirective">

      <description>
        Register an Import Handler, that is able to load a XML
        Representation of a ProcessDefinition and create
        a persistent Instance for it.
      </description>


      <attribute name="for" required="yes">
        <description>
              The interface of the process defintion, 
              this handler can load. 
          </description>
      </attribute>

      <attribute name="factory">
        <description>
              The factory for the instance that implements the handler. 
          </description>
      </attribute>

    </directive>

    <directive name="exportHandler" 
               handler=".metaconfigure.exportHandlerDirective">

      <description>
        Register an Export Handler, that is able to save a XML
        Representation of a ProcessDefinition from a given object.
      </description>


      <attribute name="for" required="yes">
        <description>
              The interface of the process defintion, 
              this handler can save. 
          </description>
      </attribute>

      <attribute name="factory">
        <description>
              The factory for the instance that implements the handler. 
          </description>
      </attribute>

    </directive>

  </directives>

</zopeConfigure>


=== Added File Packages3/workflow/metaconfigure.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 Import Export Utility

$Id: metaconfigure.py,v 1.1 2003/03/26 17:43:36 jack-e Exp $
"""
__metaclass__ = type

from zope.configuration.action import Action
from globalimportexport import globalImportExport

#

def importHandlerDirective(_context, interface, factory):
    interface = _context.resolve(interface)
    factory = _context.resolve(factory)
    return [
        Action(
              discriminator = ('workflow','importHandler', interface),
              callable = addImportHandler,
              args = (interface, factory)
              )
        ]


def exportHandlerDirective(_context, interface, factory):
    interface = _context.resolve(interface)
    factory = _context.resolve(factory)
    return [
        Action(
              discriminator = ('workflow','exportHandler', interface),
              callable = addExportHandler,
              args = (interface, factory)
              )
        ]




def addImportHandler(interface, factory):
    globalImportExport.addImportHandler(interface, factory)

def addExportHandler(interface, factory):
    globalImportExport.addExportHandler(interface, factory)



=== Packages3/workflow/README.txt 1.5 => 1.6 ===
--- Packages3/workflow/README.txt:1.5	Wed Mar 26 11:16:56 2003
+++ Packages3/workflow/README.txt	Wed Mar 26 12:43:36 2003
@@ -17,6 +17,10 @@
 
    <include package=".workflow" />
 
+ - add this to the src/zope/app/meta.zcml (after the onlinehelp entry):
+
+   <include package="zope.app.workflow" file="meta.zcml" />
+
  - link/copy the workflow/browser folder into
    src/zope/app/browser/workflow 
 
@@ -45,7 +49,8 @@
 
  - goto Servicemanager and add a WorkflowService
 
- - configure and activate that WorkflowService
+ - configure and activate that WorkflowService 
+   (press submit on the second screen ;-)
 
  - create a new package called workflows (for example)
 


=== Packages3/workflow/configure.zcml 1.6 => 1.7 ===
--- Packages3/workflow/configure.zcml:1.6	Wed Mar 26 10:24:26 2003
+++ Packages3/workflow/configure.zcml	Wed Mar 26 12:43:36 2003
@@ -67,6 +67,10 @@
 <!-- Process Definition Configuration -->
 
 <content class="zope.app.workflow.service.ProcessDefinitionConfiguration">
+  <factory
+      id="ProcessDefinitionConfiguration"
+      permission="zope.ManageServices"
+      />
   <require
       permission="zope.ManageServices"
       interface="zope.app.interfaces.workflow.IProcessDefinitionConfiguration"
@@ -85,18 +89,37 @@
 
 <!-- Process Instance Container -->
 
+<content class="zope.app.workflow.definition.ProcessDefinitionElementContainer">
+
+  <implements interface="zope.app.interfaces.container.IContentContainer" />
+
+  <implements
+     interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+     />
+
+  <require
+      permission="zope.View"
+      interface="zope.app.interfaces.container.IReadContainer"
+      />
+
+  <require
+      permission="zope.workflow.ManageProcessDefinitions"
+      interface="zope.app.interfaces.container.IWriteContainer"
+      />
+</content>
+
 <adapter factory="zope.app.workflow.instance.ProcessInstanceContainerAdapter"
          provides="zope.app.interfaces.workflow.IProcessInstanceContainer"
          for="zope.app.interfaces.annotation.IAnnotatable" />
 
 <!-- Workflow Import/Export Utility -->
-<!--
+
 <utility
-    component=".globalimportexport.globalImportExport"
+    component=".globalimportexport.globalImportExport" 
     provides="zope.app.interfaces.workflow.IProcessDefinitionImportExport"
-    permission="zope.workflow.ManageProcessDefinitions"
+    permission="zope.workflow.ManageProcessDefinitions" 
     />
--->
+
 <include package=".stateful" />
 
 </zopeConfigure>


=== Packages3/workflow/notes.txt 1.1 => 1.2 ===
--- Packages3/workflow/notes.txt:1.1	Sat Mar 22 13:17:34 2003
+++ Packages3/workflow/notes.txt	Wed Mar 26 12:43:36 2003
@@ -1,12 +1,16 @@
 ToDo:
 
 Stateful PI:
+ - care about automatic transitions
  - state-changes/data-changes need to fire events
  - sci needs probably readonly acccess to the "content-object" it applies to
 
 Stateful PD:
+ - automatic transitions
  - permissions for wf-relevant data fields
  - better initialization of wf-relevant data (e.g. missing schema)
+
+
 
 ContentWorkflowConfigurationService (CWCS):
  - replace content-workflows-utility