Conversion tabulations -> espaces.
[Plinn.git] / skins / control / content_status_modify.py
1 ## Script (Python) "content_status_modify"
2 ##parameters=workflow_action, REQUEST=None, **kw
3 ##title=Modify the status of a content object
4
5 from ZTUtils import make_query as mq
6 from Products.CMFCore.utils import getToolByName
7 from Products.CMFCore.exceptions import zExceptions_Unauthorized
8
9 wftool = getToolByName(context, 'portal_workflow')
10 mtool = getToolByName(context, 'portal_membership')
11 utool = getToolByName(context, 'portal_url')
12
13 if REQUEST :
14 kw.update(REQUEST.form)
15
16 try :
17 target = context.getActionInfo('object/history')['url']
18 except ValueError :
19 target = context.getActionInfo('object/view')['url']
20
21 res = wftool.doActionFor(context, workflow_action, **kw)
22 if res :
23 # by (Plinn) convention
24 # occurs when a ObjectMoved is raised
25 kw.update({'syncFragments' : ['Breadcrumbs', 'rightCell']})
26 return REQUEST.RESPONSE.redirect('%s?%s' % (res.absolute_url(), mq(**kw)))
27
28
29 kw.update({'portal_status_message' : 'Status changed.'})
30 try : context.id # touch something in context
31 except zExceptions_Unauthorized : target = utool()
32 return REQUEST.RESPONSE.redirect('%s?%s' % (target, mq(**kw)))