[CMF-checkins] CVS: CMF/CMFCore - WorkflowTool.py:1.18.2.1

Tres Seaver tseaver@zope.com
Fri, 4 Jan 2002 15:20:06 -0500


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv18360/CMFCore

Modified Files:
      Tag: CMF-1_2-branch
	WorkflowTool.py 
Log Message:


  - Enabled querying actions from workflow tool in absence
    of actions tool (Tracker #401).


=== CMF/CMFCore/WorkflowTool.py 1.18 => 1.18.2.1 ===
 _marker = []  # Create a new marker object.
 
+class WorkflowInformation:
+    """
+        Shim implementation of ActionInformation, to enable
+        querying actions without mediation of the 'portal_actions' tool.
+    """
+    def __init__(self, object):
+        self.content = object
+        self.content_url = object.absolute_url()
+        self.portal_url = self.folder_url = ''
+
+    def __getitem__(self, name):
+        if name[:1] == '_':
+            raise KeyError, name
+        if hasattr(self, name):
+            return getattr(self, name)
+        raise KeyError, name
+
 
 class WorkflowTool (UniqueObject, Folder):
     '''
@@ -345,6 +362,14 @@
             if v is not None:
                 vars.update(v)
         return vars
+
+    security.declarePublic('getActionsFor')
+    def getActionsFor(self, ob):
+        '''
+        Return a list of action dictionaries for 'ob', just as though
+        queried via 'ActionsTool.listFilteredActionsFor'.
+        '''
+        return self.listActions( WorkflowInformation( ob ) )
 
     security.declarePrivate('listActions')
     def listActions(self, info):