From 0be251b801d9d730a37d8daf72492aeb0c70d021 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Thu, 3 Aug 2006 15:55:35 +0000
Subject: [PATCH] Use keep_items parameter of ERP5XhtmlStyle_redirect to pass
 the portal_status_message.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9035 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Base_createNewDocument.xml                | 162 ++++++++++++++++++
 .../ERP5XhtmlStyle_doAction.xml               |  31 ++--
 .../erp5_xhtml_style/Folder_create.xml        | 160 +++++++++++++++++
 .../bootstrap/erp5_xhtml_style/bt/revision    |   2 +-
 4 files changed, 338 insertions(+), 17 deletions(-)
 create mode 100644 product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createNewDocument.xml
 create mode 100644 product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Folder_create.xml

diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createNewDocument.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createNewDocument.xml
new file mode 100644
index 0000000000..39d122d154
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Base_createNewDocument.xml
@@ -0,0 +1,162 @@
+<?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>N_ = context.getPortalObject().Base_translateString\n
+REQUEST=context.REQUEST\n
+\n
+# Add an object of the same type as self in the container.\n
+parent = context.aq_parent\n
+\n
+# XXX May be this need to be changed in order to get something else than\n
+# the permission "Add portal content"\n
+new_id = parent.generateNewId()\n
+context.portal_types.constructContent(type_name=context.portal_type,\n
+                        container=parent,\n
+                        id=str(new_id),\n
+                        RESPONSE=REQUEST.RESPONSE)\n
+\n
+return context.ERP5XhtmlStyle_redirect(\'%s/%s/view\' % (parent.getUrl(), new_id), keep_items={\'portal_status_message\': N_("Object Created.")})\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>_params</string> </key>
+            <value> <string></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>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>N_</string>
+                            <string>REQUEST</string>
+                            <string>parent</string>
+                            <string>new_id</string>
+                            <string>str</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_createNewDocument</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/ERP5XhtmlStyle_doAction.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_doAction.xml
index f91dafdbda..55dcb9c86c 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_doAction.xml
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/ERP5XhtmlStyle_doAction.xml
@@ -70,6 +70,7 @@
             <key> <string>_body</string> </key>
             <value> <string>portal = context.getPortalObject()\n
 N_ = portal.Base_translateString\n
+preserved_parameters={}\n
 \n
 Base_doAction = select_action.split()\n
 doAction0 = Base_doAction[0]\n
@@ -77,13 +78,14 @@ request = context.REQUEST\n
 \n
 # Reinject parameters in kw\n
 kw[\'selection_name\']=selection_name\n
-kw[\'uids\']=uids\n
-kw[\'listbox_uid\']=listbox_uid\n
+#uids=None, listbox_uid=None\n
+#kw[\'uids\']=uids\n
+#kw[\'listbox_uid\']=listbox_uid\n
 kw[\'ignore_layout\']=ignore_layout\n
 \n
 # Update checked uids\n
-if None not in (selection_name, uids, listbox_uid):\n
-  context.portal_selections.updateSelectionCheckedUidList(selection_name, uids=uids, listbox_uid=listbox_uid, REQUEST=request)\n
+#if None not in (selection_name, uids, listbox_uid):\n
+#  context.portal_selections.updateSelectionCheckedUidList(selection_name, uids=uids, listbox_uid=listbox_uid, REQUEST=request)\n
 \n
 # If this is an object, a workflow or a folder, then jump to that view\n
 if doAction0 in (\'object\', \'workflow\', \'folder\'):\n
@@ -97,7 +99,7 @@ elif doAction0 == \'add\':\n
   new_content = context.newContent(portal_type=type_name,\n
                                    container=context,\n
                                    id=str(new_id))\n
-  kw[\'portal_status_message\'] = N_("Object+Created.")\n
+  preserved_parameters[\'portal_status_message\'] = N_("Object Created.")\n
   if not(ignore_layout) and context.getApplicableLayout():\n
     kw[\'editable_mode\'] = 1\n
     redirect_url = \'%s/view\' % (new_content.WebSite_getDocumentPhysicalPath(), )\n
@@ -117,16 +119,16 @@ elif doAction0 == \'template\':\n
     new_content_id = new_content_list[0][\'new_id\']\n
     new_content = context[new_content_id]\n
     new_content.makeTemplateInstance()\n
-    kw[\'portal_status_message\'] = N_("Template+Created.")\n
+    preserved_parameters[\'portal_status_message\'] = N_("Template Created.")\n
     redirect_url = \'%s/view\' % ( new_content.absolute_url(), )\n
   else:\n
-    kw[\'portal_status_message\'] = N_("Template+Does+not+Exist.")\n
+    preserved_parameters[\'portal_status_message\'] = N_("Template Does not Exist.")\n
     redirect_url = \'%s/view\' % (context.absolute_url(), )\n
 else:\n
   redirect_url = request[\'ACTUAL_URL\']\n
-  kw[\'portal_status_message\'] = N_(\'Error: the action "%s" is not recognised.\' % (doAction0, ))\n
+  preserved_parameters[\'portal_status_message\'] = N_(\'Error: the action "%s" is not recognised.\' % (doAction0, ))\n
 \n
-return context.ERP5XhtmlStyle_redirect(redirect_url, **kw)\n
+return context.ERP5XhtmlStyle_redirect(redirect_url, keep_items=preserved_parameters, **kw)\n
 </string> </value>
         </item>
         <item>
@@ -143,7 +145,7 @@ return context.ERP5XhtmlStyle_redirect(redirect_url, **kw)\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>select_action, selection_name=None, uids=None, listbox_uid=None, ignore_layout=None, **kw</string> </value>
+            <value> <string>select_action, selection_name=None, ignore_layout=None, **kw</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -163,7 +165,7 @@ return context.ERP5XhtmlStyle_redirect(redirect_url, **kw)\n
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>5</int> </value>
+                        <value> <int>3</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
@@ -171,25 +173,24 @@ return context.ERP5XhtmlStyle_redirect(redirect_url, **kw)\n
                           <tuple>
                             <string>select_action</string>
                             <string>selection_name</string>
-                            <string>uids</string>
-                            <string>listbox_uid</string>
                             <string>ignore_layout</string>
                             <string>kw</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>portal</string>
                             <string>N_</string>
+                            <string>preserved_parameters</string>
                             <string>Base_doAction</string>
                             <string>_getitem_</string>
                             <string>doAction0</string>
                             <string>request</string>
                             <string>_write_</string>
-                            <string>None</string>
                             <string>redirect_url</string>
                             <string>new_id</string>
                             <string>type_name</string>
                             <string>str</string>
                             <string>new_content</string>
+                            <string>None</string>
                             <string>template_relative_url</string>
                             <string>template</string>
                             <string>preference</string>
@@ -210,8 +211,6 @@ return context.ERP5XhtmlStyle_redirect(redirect_url, **kw)\n
               <tuple>
                 <none/>
                 <none/>
-                <none/>
-                <none/>
               </tuple>
             </value>
         </item>
diff --git a/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Folder_create.xml b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Folder_create.xml
new file mode 100644
index 0000000000..e809f76841
--- /dev/null
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/SkinTemplateItem/portal_skins/erp5_xhtml_style/Folder_create.xml
@@ -0,0 +1,160 @@
+<?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>N_ = context.getPortalObject().Base_translateString\n
+\n
+# Add an object of the same type as the container\n
+# or if allowed content types is 1 add that type\n
+try:\n
+  new_object = context.newContent()\n
+except IndexError:\n
+  # return only a portal_status_message if the IndexError is raised because\n
+  # there are no elemnts in context.allowedContentTypes()\n
+  if not context.allowedContentTypes():\n
+    return context.ERP5XhtmlStyle_redirect(\'%s/view\' % (context.absolute_url(), ), keep_items={\'portal_status_message\': N_("You are not allowed to add new content in this context.")})\n
+  else:\n
+    raise\n
+\n
+return context.ERP5XhtmlStyle_redirect(\'%s/view\' % (new_object.absolute_url(), ), keep_items={\'portal_status_message\': N_("Object Created.")})\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>_params</string> </key>
+            <value> <string></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>0</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>N_</string>
+                            <string>new_object</string>
+                            <string>IndexError</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Folder_create</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/bt/revision b/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision
index d7765fe47e..9cd72aa941 100644
--- a/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision
+++ b/product/ERP5/bootstrap/erp5_xhtml_style/bt/revision
@@ -1 +1 @@
-70
\ No newline at end of file
+72
\ No newline at end of file
-- 
2.30.9