[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful - interfaces.py:1.1 configure.zcml:1.13 contentworkflow.py:1.16 definition.py:1.14 instance.py:1.19 xmlimportexport.py:1.14

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Apr 24 19:18:57 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful
In directory cvs.zope.org:/tmp/cvs-serv29442/src/zope/app/workflow/stateful

Modified Files:
	configure.zcml contentworkflow.py definition.py instance.py 
	xmlimportexport.py 
Added Files:
	interfaces.py 
Log Message:


Move code to stateful, so we can package stateful seperately.




=== Added File Zope3/src/zope/app/workflow/stateful/interfaces.py ===
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""Interfaces for stateful workflow process definition.

$Id: interfaces.py,v 1.1 2004/04/24 23:18:25 srichter Exp $
"""
import zope.schema

from zope.interface import Interface, Attribute
from zope.app.workflow.interfaces import IWorkflowEvent
from zope.app.workflow.interfaces import IProcessDefinition
from zope.app.workflow.interfaces import IProcessInstance
from zope.app.workflow.interfaces import IProcessDefinitionElementContainer

AUTOMATIC = u'Automatic'
MANUAL = u'Manual'
INITIAL = u'INITIAL'


class ITransitionEvent(IWorkflowEvent):
    """An event that signalizes a transition from one state to another."""

    object = Attribute("""The content object whose status will be changed.""")

    process = Attribute("""The process instance that is doing the
                           transition. Note that this object really represents
                           the workflow.""")

    transition = Attribute("""The transition that is being fired/executed. It
                              contains all the specific information, such as
                              source and destination state.""")


class IBeforeTransitionEvent(ITransitionEvent):
    """This event is published before a the specified transition occurs. This
    allows other objects to veto the transition."""


class IAfterTransitionEvent(ITransitionEvent):
    """This event is published after the transition. This is important for
    objects that might change permissions when changing the status."""


class IRelevantDataChangeEvent(IWorkflowEvent):
    """This event is fired, when the object's data changes and the data is
    considered 'relevant' to the workflow. The attributes of interest are
    usually defined by a so called Relevant Data Schema."""

    process = Attribute("""The process instance that is doing the
                           transition. Note that this object really represents
                           the workflow.""")

    schema = Attribute("""The schema that defines the relevant data
                          attributes.""")

    attributeName = Attribute("""Name of the attribute that is changed.""")

    oldValue = Attribute("""The old value of the attribute.""")

    newValue = Attribute("""The new value of the attribute.""")


class IBeforeRelevantDataChangeEvent(IRelevantDataChangeEvent):
    """This event is triggered before some of the workflow-relevant data is
    being changed."""


class IAfterRelevantDataChangeEvent(IRelevantDataChangeEvent):
    """This event is triggered after some of the workflow-relevant data has
    been changed."""


class IState(Interface):
    """Interface for state of a stateful workflow process definition."""
    # XXX Should at least have a title, if not a value as well

class IStatefulStatesContainer(IProcessDefinitionElementContainer):
    """Container that stores States."""



class AvailableStatesField(zope.schema.TextLine):
    """Available States."""

    def __allowed(self):
        pd = self.context.getProcessDefinition()
        return pd.getStateNames()

    allowed_values = property(__allowed)


class TriggerModeField(zope.schema.TextLine):
    """Trigger Mode."""

    def __allowed(self):
        return [MANUAL, AUTOMATIC]

    allowed_values = property(__allowed)


class ITransition(Interface):
    """Stateful workflow transition."""

    sourceState = AvailableStatesField(
        title=u"Source State",
        description=u"Name of the source state.",
        required=True)

    destinationState = AvailableStatesField(
        title=u"Destination State",
        description=u"Name of the destination state.",
        required=True)

    condition = zope.schema.TextLine(
        title=u"Condition",
        description=u"""The condition that is evaluated to decide if the
                        transition can be fired or not.""",
        required=False)

    script = zope.schema.TextLine(
        title=u"Script",
        description=u"""The script that is evaluated to decide if the
                        transition can be fired or not.""",
        required=False)

    # XXX cannot add a default value -> raises
    # ComponentLookupError: Permissions
    # required=False does not help as well
    # so for now the permission needs to be set ttw
    # till we find another solution
    permission = zope.schema.Choice(
        title=u"The permission needed to fire the Transition.",
        vocabulary="Permissions",
        required=True)


    triggerMode = TriggerModeField(
        title=u"Trigger Mode",
        description=u"How the Transition is triggered (Automatic/Manual)",
        default=u"Manual")


    def getSourceState():
        """Get Source State."""

    def setSourceState(source):
        """Set Source State."""

    def getDestinationState():
        """Get Destination State."""

    def setDestinationState(destination):
        """Set Destination State."""

    def getCondition():
        """Get Condition."""

    def setCondition(condition):
        """Set Condition."""

    def getScript():
        """Get Script."""

    def setScript(script):
        """Set Script."""

    def getPermission():
        """Get Permission."""

    def setPermission(permission):
        """Set Permission."""

    def getTriggerMode():
        """Return the TriggerMode."""

    def setTriggerMode():
        """Set TriggerMode."""

    def getProcessDefinition():
        """Return the ProcessDefinition Object."""


class IStatefulTransitionsContainer(IProcessDefinitionElementContainer):
    """Container that stores Transitions."""


class IStatefulProcessDefinition(IProcessDefinition):
    """Interface for stateful workflow process definition."""

    relevantDataSchema = zope.schema.Choice(
        title=u"Workflow-Relevant Data Schema",
        description=u"Specifies the schema that characterizes the workflow "
                    u"relevant data of a process instance, found in pd.data.",
        vocabulary="Interfaces",
        default=None,
        required=False)

    schemaPermissions = Attribute(u"A dictionary that maps set/get permissions"
                                  u"on the schema's fields. Entries looks as"
                                  u"follows: {fieldname:(set_perm, get_perm)}")

    states = Attribute("State objects container.")

    transitions = Attribute("Transition objects container.")

    def addState(name, state):
        """Add a IState to the process definition."""

    def getState(name):
        """Get the named state."""

    def removeState(name):
        """Remove a state from the process definition

        Raises ValueError exception if trying to delete the initial state.
        """

    def getStateNames():
        """Get the state names."""

    def getInitialStateName():
        """Get the name of the initial state."""

    def addTransition(name, transition):
        """Add a ITransition to the process definition."""

    def getTransition(name):
        """Get the named transition."""

    def removeTransition(name):
        """Remove a transition from the process definition."""

    def getTransitionNames():
        """Get the transition names."""

    # XXX Temporarily till we find a better solution
    def clear():
        """Clear the whole ProcessDefinition."""



class IStatefulProcessInstance(IProcessInstance):
    """Workflow process instance.

    Represents the instance of a process defined by a
    StatefulProcessDefinition.
    """

    data = Attribute("Relevant Data object.")

    def initialize():
        """Initialize the ProcessInstance.

        set Initial State and create relevant Data.
        """

    def getOutgoingTransitions():
        """Get the outgoing transitions."""

    def fireTransition(id):
        """Fire a outgoing transitions."""

    def getProcessDefinition():
        """Get the process definition for this instance."""


class IContentProcessRegistry(Interface):
    """Content Type <-> Process Definitions Registry

    This is a registry for mapping content types (interface) to workflow
    process definitions (by name).
    """

    def register(iface, name):
        """Register a new process definition (name) for the interface iface."""

    def unregister(iface, name):
        """Unregister a process (name) for a particular interface."""

    def getProcessNamesForInterface(iface):
        """Return a list of process defintion names for the particular
        interface."""

    def getInterfacesForProcessName(name):
        """Return a list of interfaces for the particular process name."""


class IContentWorkflowsManager(IContentProcessRegistry):
    """A Content Workflows Manager.

    It associates content objects with some workflow process definitions.
    """

    def subscribe():
        """Subscribe to the prevailing object hub service."""

    def unsubscribe():
        """Unsubscribe from the object hub service."""

    def isSubscribed():
        """Return whether we are currently subscribed."""

    def getProcessDefinitionNamesForObject(object):
        """Get the process definition names for a particular object.

        This method reads in all the interfaces this object implements and
        finds then the corresponding process names using the
        IContentProcessRegistry."""


=== Zope3/src/zope/app/workflow/stateful/configure.zcml 1.12 => 1.13 ===
--- Zope3/src/zope/app/workflow/stateful/configure.zcml:1.12	Fri Apr 16 07:51:47 2004
+++ Zope3/src/zope/app/workflow/stateful/configure.zcml	Sat Apr 24 19:18:25 2004
@@ -5,7 +5,7 @@
 <!-- Stateful ProcessDefintion -->
 
 <content 
-    class="zope.app.workflow.stateful.definition.StatefulProcessDefinition">
+    class=".definition.StatefulProcessDefinition">
   <factory
       id="StatefulProcessDefinition"
       />
@@ -17,8 +17,8 @@
       />
   <require
       permission="zope.workflow.ManageProcessDefinitions"
-      interface="..interfaces.stateful.IStatefulProcessDefinition"
-      set_schema="..interfaces.stateful.IStatefulProcessDefinition" 
+      interface=".interfaces.IStatefulProcessDefinition"
+      set_schema=".interfaces.IStatefulProcessDefinition" 
       />
   <require
       permission="zope.workflow.ManageProcessDefinitions"
@@ -29,13 +29,13 @@
 
 <!-- States Container -->
 
-<content class="zope.app.workflow.stateful.definition.StatesContainer">
+<content class=".definition.StatesContainer">
   <factory
       id="StatefulStatesContainer"
       />
   <require
       permission="zope.workflow.ManageProcessDefinitions"
-      interface="..interfaces.stateful.IStatefulStatesContainer"
+      interface=".interfaces.IStatefulStatesContainer"
       />
   <implements 
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" 
@@ -44,14 +44,14 @@
 
 <!-- State -->
 
-<content class="zope.app.workflow.stateful.definition.State">
+<content class=".definition.State">
   <factory
       id="StatefulState"
       />
   <require
       permission="zope.workflow.ManageProcessDefinitions"
-      interface="zope.app.workflow.interfaces.stateful.IState"
-      set_schema="zope.app.workflow.interfaces.stateful.IState"
+      interface=".interfaces.IState"
+      set_schema=".interfaces.IState"
       />
   <implements 
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" 
@@ -60,13 +60,13 @@
 
 <!-- Transitions Container -->
 
-<content class="zope.app.workflow.stateful.definition.TransitionsContainer">
+<content class=".definition.TransitionsContainer">
   <factory
       id="StatefulTransitionsContainer"
       />
   <require
       permission="zope.workflow.ManageProcessDefinitions"
-      interface="..interfaces.stateful.IStatefulTransitionsContainer" 
+      interface=".interfaces.IStatefulTransitionsContainer" 
       />
   <implements 
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" 
@@ -75,14 +75,14 @@
 
 <!-- Transition -->
 
-<content class="zope.app.workflow.stateful.definition.Transition">
+<content class=".definition.Transition">
   <factory
       id="StatefulTransition"
       />
   <require
       permission="zope.workflow.ManageProcessDefinitions"
-      interface="zope.app.workflow.interfaces.stateful.ITransition" 
-      set_schema="zope.app.workflow.interfaces.stateful.ITransition"
+      interface=".interfaces.ITransition" 
+      set_schema=".interfaces.ITransition"
       />
   <implements 
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" 
@@ -98,25 +98,27 @@
   />
   <require
     permission="zope.ManageServices"
-    interface="zope.app.workflow.interfaces.stateful.IContentWorkflowsManager"
+    interface=".interfaces.IContentWorkflowsManager"
     attributes="cpRegistry"
     />
 </content>
 
 <!-- Stateful workflow import/Export -->
 <adapter
-   for="zope.app.workflow.interfaces.stateful.IStatefulProcessDefinition"
+   for=".interfaces.IStatefulProcessDefinition"
    provides="zope.app.workflow.interfaces.IProcessDefinitionExportHandler"
    factory=".xmlimportexport.XMLExportHandler"
    />
 
 <adapter
-   for="zope.app.workflow.interfaces.stateful.IStatefulProcessDefinition"
+   for=".interfaces.IStatefulProcessDefinition"
    provides="zope.app.workflow.interfaces.IProcessDefinitionImportHandler"
    factory=".xmlimportexport.XMLImportHandler"
    />
 
 <!-- Test Object for testing Stateful Workflows -->
 <!--include file="testobject.zcml"/-->
+
+<include package=".browser" />
 
 </configure>


=== Zope3/src/zope/app/workflow/stateful/contentworkflow.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/workflow/stateful/contentworkflow.py:1.15	Thu Apr 15 18:11:09 2004
+++ Zope3/src/zope/app/workflow/stateful/contentworkflow.py	Sat Apr 24 19:18:25 2004
@@ -27,7 +27,7 @@
 
 from zope.app.workflow.interfaces import IProcessInstanceContainer
 from zope.app.workflow.interfaces import IProcessInstanceContainerAdaptable
-from zope.app.workflow.interfaces.stateful import IContentWorkflowsManager
+from zope.app.workflow.stateful.interfaces import IContentWorkflowsManager
 from zope.app.workflow.instance import createProcessInstance
 from zope.interface import implements, providedBy
 from zope.app.container.contained import Contained


=== Zope3/src/zope/app/workflow/stateful/definition.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/workflow/stateful/definition.py:1.13	Wed Mar  3 15:20:35 2004
+++ Zope3/src/zope/app/workflow/stateful/definition.py	Sat Apr 24 19:18:25 2004
@@ -20,10 +20,10 @@
 from zope.interface import implements
 
 from zope.app.container.interfaces import IReadContainer
-from zope.app.workflow.interfaces.stateful import IStatefulProcessDefinition
-from zope.app.workflow.interfaces.stateful import IState, ITransition, INITIAL
-from zope.app.workflow.interfaces.stateful import IStatefulStatesContainer
-from zope.app.workflow.interfaces.stateful import IStatefulTransitionsContainer
+from zope.app.workflow.stateful.interfaces import IStatefulProcessDefinition
+from zope.app.workflow.stateful.interfaces import IState, ITransition, INITIAL
+from zope.app.workflow.stateful.interfaces import IStatefulStatesContainer
+from zope.app.workflow.stateful.interfaces import IStatefulTransitionsContainer
 
 from zope.app.container.contained import Contained
 from zope.app.workflow.definition import ProcessDefinition


=== Zope3/src/zope/app/workflow/stateful/instance.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/workflow/stateful/instance.py:1.18	Thu Apr 15 18:11:34 2004
+++ Zope3/src/zope/app/workflow/stateful/instance.py	Sat Apr 24 19:18:25 2004
@@ -21,14 +21,14 @@
 from zope.app import zapi
 from zope.app.event import publish
 from zope.app.workflow.interfaces import IProcessDefinition
-from zope.app.workflow.interfaces.stateful import AUTOMATIC
-from zope.app.workflow.interfaces.stateful import IAfterTransitionEvent
-from zope.app.workflow.interfaces.stateful import IBeforeTransitionEvent
-from zope.app.workflow.interfaces.stateful import IRelevantDataChangeEvent
-from zope.app.workflow.interfaces.stateful import IStatefulProcessInstance
-from zope.app.workflow.interfaces.stateful import ITransitionEvent
-from zope.app.workflow.interfaces.stateful import IBeforeRelevantDataChangeEvent
-from zope.app.workflow.interfaces.stateful import IAfterRelevantDataChangeEvent
+from zope.app.workflow.stateful.interfaces import AUTOMATIC
+from zope.app.workflow.stateful.interfaces import IAfterTransitionEvent
+from zope.app.workflow.stateful.interfaces import IBeforeTransitionEvent
+from zope.app.workflow.stateful.interfaces import IRelevantDataChangeEvent
+from zope.app.workflow.stateful.interfaces import IStatefulProcessInstance
+from zope.app.workflow.stateful.interfaces import ITransitionEvent
+from zope.app.workflow.stateful.interfaces import IBeforeRelevantDataChangeEvent
+from zope.app.workflow.stateful.interfaces import IAfterRelevantDataChangeEvent
 from zope.app.servicenames import Utilities
 from zope.app.traversing import getParent
 from zope.app.workflow.instance import ProcessInstance


=== Zope3/src/zope/app/workflow/stateful/xmlimportexport.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/workflow/stateful/xmlimportexport.py:1.13	Fri Apr 16 07:51:55 2004
+++ Zope3/src/zope/app/workflow/stateful/xmlimportexport.py	Sat Apr 24 19:18:26 2004
@@ -28,10 +28,10 @@
 from zope.app.dublincore.interfaces import IZopeDublinCore
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 from zope.app.security.interfaces import IPermission 
-from zope.app.workflow.interfaces.stateful import IStatefulProcessDefinition
 from zope.app.workflow.interfaces import IProcessDefinitionImportHandler
 from zope.app.workflow.interfaces import IProcessDefinitionExportHandler
 from zope.app.workflow.stateful.definition import State, Transition
+from zope.app.workflow.stateful.interfaces import IStatefulProcessDefinition
 
 
 # basic implementation for a format-checker




More information about the Zope3-Checkins mailing list