[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/workflow - __init__.py:1.17 stateful.py:1.17

Stephan Richter srichter@cosmos.phy.tufts.edu
Wed, 30 Jul 2003 11:24:41 -0400


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

Modified Files:
	__init__.py stateful.py 
Log Message:
This is a good checkpoint and I am going to check this stuff in...

  - Created Workflow events and enhanced some tests to test for them being
    published correctly.

  - Revived RelevantData and compacted the code. I threw out all of the 
    checker code for now. I have a feeling that we ain't gotta need it. 

The last steps are:

  - Being able to specify permissions (set and get) for each field of the 
    RelevantData Schema.

  - View/Modify the RelevantData in a Process Instance.

Once I am done with that, I think that the workflow code is in a good state
for the beta.



=== Zope3/src/zope/app/interfaces/workflow/__init__.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/interfaces/workflow/__init__.py:1.16	Tue Jul 29 20:00:19 2003
+++ Zope3/src/zope/app/interfaces/workflow/__init__.py	Wed Jul 30 11:24:06 2003
@@ -20,9 +20,16 @@
 from zope.interface import Interface
 from zope.interface import Attribute
 from zope.app.interfaces.container import IContainer
+from zope.app.interfaces.event import IEvent
 from zope.app.interfaces.services.registration \
      import INamedComponentRegistration
 from zope.app.interfaces.services.registration import ComponentPath
+
+
+class IWorkflowEvent(IEvent):
+    """This event describes a generic event that is triggered by the workflow
+    mechanism.""" 
+
 
 class IWorkflowService(Interface):
     """Workflow service.


=== Zope3/src/zope/app/interfaces/workflow/stateful.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/interfaces/workflow/stateful.py:1.16	Tue Jul 29 20:00:19 2003
+++ Zope3/src/zope/app/interfaces/workflow/stateful.py	Wed Jul 30 11:24:06 2003
@@ -21,10 +21,66 @@
 from zope.app.security.permission import PermissionField
 
 from zope.interface import Interface, Attribute
+from zope.app.interfaces.workflow import IWorkflowEvent
 from zope.app.interfaces.workflow import IProcessDefinition
 from zope.app.interfaces.workflow import IProcessInstance
 from zope.app.interfaces.workflow import IProcessDefinitionElementContainer
 
+AUTOMATIC = u'Automatic'
+MANUAL = u'Manual'
+
+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."""
@@ -49,8 +105,7 @@
     """Trigger Mode."""
 
     def __allowed(self):
-        # XXX Need to define Contants !!!
-        return [u'Manual', u'Automatic']
+        return [MANUAL, AUTOMATIC]
     
     allowed_values = ContextProperty(__allowed)
 
@@ -136,14 +191,10 @@
         """Return the ProcessDefinition Object."""
 
 
-
-
 class IStatefulTransitionsContainer(IProcessDefinitionElementContainer):
     """Container that stores Transitions."""
 
 
-
-
 class IStatefulProcessDefinition(IProcessDefinition):
     """Interface for stateful workflow process definition."""
 
@@ -222,6 +273,9 @@
     def fireTransition(id):
         """Fire a outgoing transitions."""
 
+    def getProcessDefinition():
+        """Get the process definition for this instance."""
+        
 
 class IContentProcessRegistry(Interface):
     """Content Type <-> Process Definitions Registry