Back to index

plone3  3.1.7
setRedirect.py
Go to the documentation of this file.
00001 ##parameters=provider, action_path, **kw
00002 ##
00003 from ZTUtils import make_query
00004 from Products.CMFCore.utils import getToolByName
00005 from Products.CMFDefault.utils import getBrowserCharset
00006 
00007 utool = getToolByName(script, 'portal_url')
00008 portal_url = utool()
00009 
00010 
00011 try:
00012     target = provider.getActionInfo(action_path)['url']
00013 except ValueError:
00014     target = portal_url
00015 
00016 message = context.REQUEST.other.get('portal_status_message', '')
00017 if message:
00018     if isinstance(message, unicode):
00019         message = unicode(message).encode(getBrowserCharset(context.REQUEST))
00020     kw['portal_status_message'] = message
00021 for k, v in kw.items():
00022     if not v:
00023         del kw[k]
00024 
00025 query = kw and ( '?%s' % make_query(kw) ) or ''
00026 context.REQUEST.RESPONSE.redirect( '%s%s' % (target, query) )
00027 
00028 return True