Patch de Products.CMFDefault.formlib.form._EditFormMixin._setRedirect Plinn implement...
authorBenoît Pin <benoit.pin@gmail.com>
Wed, 11 Dec 2013 21:23:20 +0000 (22:23 +0100)
committerBenoît Pin <benoit.pin@gmail.com>
Wed, 11 Dec 2013 21:23:20 +0000 (22:23 +0100)
patch.py
patch_impl.py [new file with mode: 0644]

index fe60513..5f99887 100644 (file)
--- 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 (file)
index 0000000..32b0500
--- /dev/null
@@ -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 ''