From e1156e7b33a4336d4cc6f7dea46a335c8277d65b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 11 Dec 2013 22:23:20 +0100 Subject: [PATCH] =?utf8?q?Patch=20de=20Products.CMFDefault.formlib.form.?= =?utf8?q?=5FEditFormMixin.=5FsetRedirect=20Plinn=20implementation=20pour?= =?utf8?q?=20prendre=20en=20compte=20le=20drapeau=20=C2=AB=C2=A0ajax=C2=A0?= =?utf8?q?=C2=BB=20lors=20de=20la=20redirection=20apr=C3=A8s=20traitement?= =?utf8?q?=20du=20formulaire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- patch.py | 7 ++++++- patch_impl.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 patch_impl.py diff --git a/patch.py b/patch.py index fe60513..5f99887 100644 --- a/patch.py +++ b/patch.py @@ -25,4 +25,9 @@ CMFPortalFolder.listCatalogedContents = PlinnFolder.listCatalogedContents.im_fun cmfPortalFolderSecurity.declareProtected(AddPortalContent, 'put_upload') CMFPortalFolder.put_upload = PlinnFolder.put_upload.im_func -cmfPortalFolderSecurity.apply(CMFPortalFolder) \ No newline at end of file +cmfPortalFolderSecurity.apply(CMFPortalFolder) + + +from Products.CMFDefault.formlib.form import _EditFormMixin +from patch_impl import _setRedirect +_EditFormMixin._setRedirect = _setRedirect \ No newline at end of file diff --git a/patch_impl.py b/patch_impl.py new file mode 100644 index 0000000..32b0500 --- /dev/null +++ b/patch_impl.py @@ -0,0 +1,32 @@ +from ZTUtils import make_query +from Products.CMFCore.utils import getToolByName +from Products.CMFDefault.exceptions import zExceptions_Unauthorized +from Products.CMFDefault.utils import translate + +def _setRedirect(self, provider_id, action_path, keys=''): + # Products.CMFDefault.formlib.form._EditFormMixin._setRedirect Plinn implementation + provider = getToolByName(self.context, provider_id) + try: + target = provider.getActionInfo(action_path, self.context, + check_condition=1)['url'] + except (ValueError, zExceptions_Unauthorized): + target = self._getPortalURL() + + kw = {} + if self.status: + message = translate(self.status, self.context) + if isinstance(message, unicode): + message = message.encode(self._getBrowserCharset()) + kw['portal_status_message'] = message + for k in keys.split(','): + k = k.strip() + v = self.request.form.get(k, None) + if v: + kw[k] = v + + if self.request.form.has_key('ajax') : + kw['ajax'] = self.request.form['ajax'] + query = kw and ('?%s' % make_query(kw)) or '' + self.request.RESPONSE.redirect('%s%s' % (target, query)) + + return '' -- 2.20.1