Back to index

plone3  3.1.7
content_status_modify.py
Go to the documentation of this file.
00001 ##parameters=workflow_action, comment=''
00002 ##title=Modify the status of a content object
00003 ##
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFDefault.exceptions import WorkflowException
00006 from Products.CMFDefault.utils import Message as _
00007 
00008 wtool = getToolByName(script, 'portal_workflow')
00009 
00010 try:
00011     wtool.doActionFor(context, workflow_action, comment=comment)
00012     context.setStatus(True, _(u'Status changed.'))
00013     context.setRedirect(context, 'object/view')
00014 except WorkflowException, errmsg:
00015     context.setStatus(False, errmsg)
00016     context.setRedirect(context, 'object/edit')