lint.
[Plinn.git] / Products / Plinn / patch_impl.py
1 from ZTUtils import make_query
2 from Products.CMFCore.utils import getToolByName
3 from Products.CMFDefault.exceptions import zExceptions_Unauthorized
4 from Products.CMFDefault.utils import translate
5
6 def _setRedirect(self, provider_id, action_path, keys=''):
7 # Products.CMFDefault.formlib.form._EditFormMixin._setRedirect Plinn implementation
8 provider = getToolByName(self.context, provider_id)
9 try:
10 target = provider.getActionInfo(action_path, self.context,
11 check_condition=1)['url']
12 except (ValueError, zExceptions_Unauthorized):
13 target = self._getPortalURL()
14
15 kw = {}
16 if self.status:
17 message = translate(self.status, self.context)
18 if isinstance(message, unicode):
19 message = message.encode(self._getBrowserCharset())
20 kw['portal_status_message'] = message
21 for k in keys.split(','):
22 k = k.strip()
23 v = self.request.form.get(k, None)
24 if v:
25 kw[k] = v
26
27 if self.request.form.has_key('ajax') :
28 kw['ajax'] = self.request.form['ajax']
29 query = kw and ('?%s' % make_query(kw)) or ''
30 self.request.RESPONSE.redirect('%s%s' % (target, query))
31
32 return ''