[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Workflow/Stateful - BasicStatefulProcessDefinition.py:1.1.2.1 IBasicTransition.py:1.1.2.1 IState.py:1.1.2.3 IStatefulProcessDefinition.py:1.1.2.2 ITransition.py:1.1.2.3

Florent Guillaume fg@nuxeo.com
Fri, 6 Dec 2002 05:59:39 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Workflow/Stateful
In directory cvs.zope.org:/tmp/cvs-serv16189/Stateful

Modified Files:
      Tag: sprintathon-wf-branch
	IState.py IStatefulProcessDefinition.py ITransition.py 
Added Files:
      Tag: sprintathon-wf-branch
	BasicStatefulProcessDefinition.py IBasicTransition.py 
Log Message:
First checkin, partial sync.

=== Added File Zope3/lib/python/Zope/App/Workflow/Stateful/BasicStatefulProcessDefinition.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.
#
##############################################################################
"""Basic stateful workflow process definition.

$Id: BasicStatefulProcessDefinition.py,v 1.1.2.1 2002/12/06 10:59:39 efge Exp $
"""

__metaclass__ = type

from Persistence import Persistent
from Persistence.PersistentDict import PersistentDict
from Zope.ContextWrapper import ContextMethod
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.Workflow.IProcessDefinition import IProcessDefinition
from Zope.App.Workflow.ProcessDefinition import ProcessDefinition

from Zope.App.Workflow.Stateful.IStatefulProcessDefinition import \
     IStatefulProcessDefinition
from Zope.App.Workflow.Stateful.IState import IState
from Zope.App.Workflow.Stateful.IBasicTransition import IBasicTransition


class BasicState:
    """Basic state."""

    __implements__ = IState


class BasicTransition:
    """Basic transition."""

    __implements__ = IBasicTransition

    def __init__(self, source, destination, condition):
        super(BasicTransition, self).__init__()
        self._source = source
        self._destination = destination
        self._condition = condition

    sourceState = property(lambda self: self._source)

    destinationState = property(lambda self: self._destination)

    condition = property(lambda self: self._condition)


class BasicStatefulProcessDefinition(ProcessDefinition):
    """Basic stateful workflow process definition."""

    __implements__ = IStatefulProcessDefinition

    def __init__(self):
        super(BasicStatefulProcessDefinition, self).__init__(self)
        self.__states = grPersistentDict()
        initial = BasicState()
        self.__states[self.getInitialStateName()] = initial
        self.__transitions = PersistentDict()

    ############################################################
    # Implementation methods for interface
    # Zope.App.Workflow.Stateful.IStatefulProcessDefinition

    def addState(self, name, state):
        if name in self.__states:
            raise KeyError, name
        self.__states[name] = state

    def getState(self, name):
        return ContextWrapper(self.__states[name], self)
    getState = ContextMethod(getState)

    def removeState(self, name):
        del self.__states[name]

    def getStateNames(self):
        return self.__states.keys()

    def getInitialStateName(self):
        return 'INITIAL'

    def addTransition(self, name, transition):
        if name in self.__transitions:
            raise KeyError, name
        self.__transitions[name] = state

    def getTransition(self, name):
        return ContextWrapper(self.__transitions[name], self)
    getTransition = ContextMethod(getTransition)

    def removeTransition(self, name):
        del self.__transitions[name]

    def getTransitionNames(self):
        return self.__transitions.keys()

    # IProcessDefinition

    def createProcessInstance(self):
        pass

    #
    ############################################################


=== Added File Zope3/lib/python/Zope/App/Workflow/Stateful/IBasicTransition.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.
#
##############################################################################

"""Interfaces for a workflow transition.

$Id: IBasicTransition.py,v 1.1.2.1 2002/12/06 10:59:39 efge Exp $
"""

from Interface import Interface
from Interface.Attribute import Attribute

from Zope.App.Workflow.Stateful.ITransition import ITransition


class IBasicTransition(ITransition):
    """Basic stateful workflow transition."""

    sourceState = Attribute("Name of the source state.")


=== Zope3/lib/python/Zope/App/Workflow/Stateful/IState.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/lib/python/Zope/App/Workflow/Stateful/IState.py:1.1.2.2	Thu Dec  5 11:00:14 2002
+++ Zope3/lib/python/Zope/App/Workflow/Stateful/IState.py	Fri Dec  6 05:59:39 2002
@@ -24,9 +24,4 @@
 class IState(Interface):
     """Interface for state of a stateful workflow process definition."""
 
-    def addOutgoingTransition(name):
-        """Add an outgoing transition."""
-
-    def deleteOutgoingTransition(name):
-        """Delete an outgoing transition."""
-
+    # nothing is defined


=== Zope3/lib/python/Zope/App/Workflow/Stateful/IStatefulProcessDefinition.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/lib/python/Zope/App/Workflow/Stateful/IStatefulProcessDefinition.py:1.1.2.1	Thu Dec  5 11:44:39 2002
+++ Zope3/lib/python/Zope/App/Workflow/Stateful/IStatefulProcessDefinition.py	Fri Dec  6 05:59:39 2002
@@ -29,6 +29,9 @@
     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
 
@@ -43,6 +46,9 @@
 
     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."""


=== Zope3/lib/python/Zope/App/Workflow/Stateful/ITransition.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/lib/python/Zope/App/Workflow/Stateful/ITransition.py:1.1.2.2	Thu Dec  5 11:00:14 2002
+++ Zope3/lib/python/Zope/App/Workflow/Stateful/ITransition.py	Fri Dec  6 05:59:39 2002
@@ -1,15 +1,15 @@
 ##############################################################################
 #
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# 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.
-# 
+#
 ##############################################################################
 
 """Interfaces for a workflow transition.
@@ -20,10 +20,11 @@
 from Interface import Interface
 from Interface.Attribute import Attribute
 
+
 class ITransition(Interface):
-    """Interface for a stateful workflow transition."""
+    """Stateful workflow transition."""
+
+    destinationState = Attribute("Name of the destination state.")
 
-    destinationState = Attribute("name of the destination state")
-    condition = Attribute("""The condition that has evaluated to decide if \
-                             to fire the condition or not""")
-                             
+    condition = Attribute("""The condition that is evaluated to decide if \
+                             the condition is fired or not.""")