Back to index

plone3  3.1.7
redirectToDiscussable.py
Go to the documentation of this file.
00001 ## Script (Python) "redirectToDiscussable"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=
00008 ##title=Redirect from a discussionItem to it's absolute parent (discussable object)
00009 ##
00010 
00011 from Products.CMFCore.utils import getToolByName
00012 
00013 if context.portal_type == 'Discussion Item':
00014     pu = getToolByName(context, "plone_utils")
00015     redirect_target = pu.getDiscussionThread(context)[0]
00016     state = redirect_target.restrictedTraverse("@@plone_context_state")
00017   
00018     context.REQUEST.response.redirect(state.view_url() + '#' + context.id)