Back to index

plone3  3.1.7
getWorkflowHistory.py
Go to the documentation of this file.
00001 ## Script (Python) "getWorkflowHistory"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=
00008 ##title=Return the workflow history for an object
00009 ##
00010 
00011 from Products.CMFCore.WorkflowCore import WorkflowException
00012 from Products.CMFPlone.utils import log
00013 
00014 history = []
00015 
00016 # check if the current user has the proper permissions
00017 if context.portal_membership.checkPermission('Modify portal content', context):
00018 
00019     try:
00020         # get total history
00021         review_history =context.portal_workflow.getInfoFor(context, 'review_history')
00022 
00023         # filter out the irrelevant stuff
00024         review_history = [r for r in review_history if r['action']]
00025 
00026         #reverse the list
00027         history = context.reverseList(review_history)
00028 
00029     except WorkflowException:
00030         log( 'CMFPlone/skins/plone_scripts/getWorkflowHistory: '
00031              '%s has no associated workflow' % context.absolute_url() )
00032 
00033 return history