implements 'parent' method on workflow entity types stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 03 Dec 2009 09:57:32 +0100
branchstable
changeset 3982 ac2a54a6f36f
parent 3981 8029019884af
child 3983 e2dc12753436
implements 'parent' method on workflow entity types
entities/wfobjs.py
--- a/entities/wfobjs.py	Thu Dec 03 09:56:53 2009 +0100
+++ b/entities/wfobjs.py	Thu Dec 03 09:57:32 2009 +0100
@@ -34,6 +34,7 @@
         return any(et for et in self.reverse_default_workflow
                    if et.name == etype)
 
+    # XXX define parent() instead? what if workflow of multiple types?
     def after_deletion_path(self):
         """return (path, parameters) which should be used as redirect
         information when this entity is being deleted
@@ -244,6 +245,9 @@
     def destination(self):
         return self.destination_state[0]
 
+    def parent(self):
+        return self.workflow
+
 
 class WorkflowTransition(BaseTransition):
     """customized class for WorkflowTransition entities"""
@@ -309,6 +313,9 @@
     def destination(self):
         return self.destination_state and self.destination_state[0] or None
 
+    def parent(self):
+        return self.reverse_subworkflow_exit[0]
+
 
 class State(AnyEntity):
     """customized class for State entities"""
@@ -321,13 +328,8 @@
         # take care, may be missing in multi-sources configuration
         return self.state_of and self.state_of[0]
 
-    def after_deletion_path(self):
-        """return (path, parameters) which should be used as redirect
-        information when this entity is being deleted
-        """
-        if self.state_of:
-            return self.state_of[0].rest_path(), {}
-        return super(State, self).after_deletion_path()
+    def parent(self):
+        return self.workflow
 
 
 class TrInfo(AnyEntity):
@@ -352,13 +354,8 @@
     def transition(self):
         return self.by_transition and self.by_transition[0] or None
 
-    def after_deletion_path(self):
-        """return (path, parameters) which should be used as redirect
-        information when this entity is being deleted
-        """
-        if self.for_entity:
-            return self.for_entity.rest_path(), {}
-        return 'view', {}
+    def parent(self):
+        return self.for_entity
 
 
 class WorkflowableMixIn(object):