From 20c1c4bc4c42bdfdcf61224ca6082ec3ddaa5d32 Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Fri, 29 Dec 2006 10:18:27 +0000
Subject: [PATCH] 2006-12-29 JPS - Updated redirect scripts to simplify API.
 More factoring needed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11792 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_xhtml_style/Base_redirect.xml        | 196 ++++++++++++++++++
 .../erp5_xhtml_style/ERP5Site_redirect.xml    |   2 +
 2 files changed, 198 insertions(+)
 create mode 100644 product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_redirect.xml

diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_redirect.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_redirect.xml
new file mode 100644
index 0000000000..e3fdcfdb4b
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_redirect.xml
@@ -0,0 +1,196 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>Products.PythonScripts.PythonScript</string>
+          <string>PythonScript</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Python_magic</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string encoding="cdata"><![CDATA[
+
+"""\n
+   This script factorises code required to redirect to the appropriate\n
+   page from a script. It should probably be extended, reviewed and documented\n
+   so that less code is copied and pasted in dialog scripts.\n
+\n
+   TODO: improve API and extensively document.\n
+"""\n
+from ZTUtils import make_query\n
+request_form = context.REQUEST.form\n
+request_form.update(kw)\n
+request_form = context.ERP5Site_filterParameterList(request_form)\n
+request_form.update(keep_items)\n
+\n
+redirect_url = \'%s/%s\' % (context.absolute_url(), form_id)\n
+\n
+parameters = make_query(dict([(k, v) for k, v in request_form.items() if k and v is not None]))\n
+if len(parameters):\n
+  if \'?\' in redirect_url:\n
+    separator = \'&\'\n
+  else:\n
+    separator = \'?\'\n
+  redirect_url = \'%s%s%s\' % (redirect_url, separator, parameters)\n
+\n
+return context.REQUEST.RESPONSE.redirect( redirect_url )\n
+
+
+]]></string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_filepath</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_owner</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>form_id=\'view\', keep_items={}, **kw</string> </value>
+        </item>
+        <item>
+            <key> <string>errors</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_code</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>co_argcount</string> </key>
+                        <value> <int>2</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>form_id</string>
+                            <string>keep_items</string>
+                            <string>kw</string>
+                            <string>ZTUtils</string>
+                            <string>make_query</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>request_form</string>
+                            <string>redirect_url</string>
+                            <string>dict</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>k</string>
+                            <string>v</string>
+                            <string>None</string>
+                            <string>parameters</string>
+                            <string>len</string>
+                            <string>separator</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <string>view</string>
+                <dictionary/>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_redirect</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5Site_redirect.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5Site_redirect.xml
index 6bba954d6f..709e92a734 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5Site_redirect.xml
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5Site_redirect.xml
@@ -76,6 +76,8 @@ request_form.update(kw)\n
 request_form = context.ERP5Site_filterParameterList(request_form)\n
 request_form.update(keep_items)\n
 \n
+# JPS-XXX Why ERP5Site ? not Base ? \n
+\n
 if redirect_url is None:\n
   redirect_url = \'%s/view\' % (context.getPortalObject().absolute_url())\n
 \n
-- 
2.30.9