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

Ulrich Eck ueck@net-labs.de
Fri, 7 Feb 2003 10:26:31 -0500


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

Modified Files:
	__init__.py stateful.py 
Log Message:
use schema attributes for Transition, State, ProcessDefinition (stateful)
minor fixes/enhancements 


=== Zope3/src/zope/app/interfaces/workflow/__init__.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/interfaces/workflow/__init__.py:1.5	Wed Feb  5 20:03:51 2003
+++ Zope3/src/zope/app/interfaces/workflow/__init__.py	Fri Feb  7 10:26:30 2003
@@ -82,6 +82,9 @@
     """
 
 
+    def getProcessDefinition():
+        """Return the ProcessDefinition Object.
+        """
 
 
 class IProcessInstance(Interface):


=== Zope3/src/zope/app/interfaces/workflow/stateful.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/interfaces/workflow/stateful.py:1.5	Thu Feb  6 16:54:13 2003
+++ Zope3/src/zope/app/interfaces/workflow/stateful.py	Fri Feb  7 10:26:30 2003
@@ -16,6 +16,10 @@
 
 $Id$
 """
+import zope.schema
+from zope.proxy.context import ContextProperty
+from zope.app.security.permission import PermissionField
+
 from zope.interface import Interface, Attribute
 from zope.app.interfaces.workflow import IProcessDefinition
 from zope.app.interfaces.workflow import IProcessInstance
@@ -33,18 +37,68 @@
 
 
 
+class AvailableStatesField(zope.schema.TextLine):
+    """Available States.
+    """
+
+    def __allowed(self):
+        pd = self.context.getProcessDefinition()
+        return pd.getStateNames()
+
+    allowed_values = ContextProperty(__allowed)
+
+
 class ITransition(Interface):
     """Stateful workflow transition.
     """
 
-    sourceState = Attribute("Name of the source state.")
+    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 condition is fired or not.",
+        required=False)
+
+    permission = PermissionField(
+        title=u"The permission needed to fire the Transition.")
 
-    destinationState = Attribute("Name of the destination state.")
 
-    condition = Attribute("""The condition that is evaluated to decide if \
-                             the condition is fired or not.""")
+    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 getPermission():
+        """Get Permission."""
+
+    def setPermission(permission):
+        """Set Permission."""
+
+    def getProcessDefinition():
+        """Return the ProcessDefinition Object.
+        """
 
-    permission = Attribute("Permission for this Transition.")
 
 
 class IStatefulTransitionsContainer(IProcessDefinitionElementContainer):
@@ -58,8 +112,23 @@
     """Interface for stateful workflow process definition.
     """
 
-    # more methods/attributes to come
-    # relevantData - Permissions (checker)
+    # XXX How to specify permissions for RelevantData ??
+
+    relevantDataSchema = zope.schema.TextLine(
+        title=u"RelevantData Schema",
+        description=u"Dotted Name of RelevantData Schema.",
+        required=True)
+
+
+    def setRelevantDataSchema(schema):
+        """Set the Schema for RelevantData.
+        """
+
+    def getRelevantDataSchema():
+        """Return the Schema for RelevantData.
+        """
+
+
 
     states = Attribute("State objects container.")
 
@@ -101,14 +170,6 @@
     
     def getTransitionNames():
         """Get the transition names.
-        """
-
-    def setSchema(schema):
-        """Set the Schema for RelevantData.
-        """
-
-    def getSchema():
-        """Return the Schema for RelevantData.
         """