[Erp5-report] r9442 - in /erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins: ./ erp5_we...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Aug 25 15:13:06 CEST 2006


Author: kevin
Date: Fri Aug 25 15:13:04 2006
New Revision: 9442

URL: http://svn.erp5.org?rev=9442&view=rev
Log:
Move admin toolbox specific scripts to brand new web widget libray folder.

Added:
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_getCopyOfReference.xml
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_newContent.xml
Modified:
    erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library.xml

Modified: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library.xml?rev=9442&r1=9441&r2=9442&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library.xml (original)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library.xml Fri Aug 25 15:13:04 2006
@@ -19,6 +19,12 @@
             </value>
         </item>
         <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
             <key> <string>id</string> </key>
             <value> <string>erp5_web_widget_library</string> </value>
         </item>

Added: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml?rev=9442&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml (added)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox.xml Fri Aug 25 15:13:04 2006
@@ -1,0 +1,38 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <tuple>
+          <string>OFS.Folder</string>
+          <string>Folder</string>
+        </tuple>
+        <none/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_objects</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>admin_toolbox</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Added: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_getCopyOfReference.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_getCopyOfReference.xml?rev=9442&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_getCopyOfReference.xml (added)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_getCopyOfReference.xml Fri Aug 25 15:13:04 2006
@@ -1,0 +1,197 @@
+<?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>if ref in (\'\', None):\n
+  return \'\'\n
+\n
+### Main function that compute the increased id\n
+def getCopyId(id):\n
+  # User ask a second copy of a copied object, so add a number in the prefix\n
+  if id.startswith(\'copy-of-\'):\n
+    return \'copy2-of-\' + id[8:]\n
+\n
+  # Return an increased "copyXXX-of-" prefix\n
+  if id.startswith(\'copy\'):\n
+    tmp_id = id[4:]\n
+    digit_prefix = 0\n
+    for i in range(len(tmp_id)):\n
+      if tmp_id[i].isdigit():\n
+        digit_prefix = (digit_prefix *10) + int(tmp_id[i])\n
+      else:\n
+        break\n
+    tmp_id = tmp_id[len(str(digit_prefix)):]\n
+    if tmp_id.startswith(\'-of-\'):\n
+      return \'copy%s-of-%s\' % (digit_prefix+1, tmp_id[4:])\n
+\n
+  # Add simple "copy-of" prefix\n
+  return \'copy-of-\' + id\n
+\n
+\n
+\n
+# Get a list of all references in webpage_module\n
+portal_object = context.getPortalObject()\n
+webpage_module = portal_object[\'web_page_module\']\n
+ref_list = map(lambda x: x.getReference(), webpage_module.objectValues())\n
+\n
+# Get an original and somehow unique reference\n
+new_ref = getCopyId(ref)\n
+while (new_ref in ref_list):\n
+  new_ref = getCopyId(new_ref)\n
+\n
+return new_ref\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>ref = None</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>1</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>ref</string>
+                            <string>None</string>
+                            <string>getCopyId</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>portal_object</string>
+                            <string>_getitem_</string>
+                            <string>webpage_module</string>
+                            <string>map</string>
+                            <string>ref_list</string>
+                            <string>new_ref</string>
+                          </tuple>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>func_defaults</string> </key>
+            <value>
+              <tuple>
+                <none/>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>WebSite_getCopyOfReference</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Added: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_newContent.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_newContent.xml?rev=9442&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_newContent.xml (added)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/admin_toolbox/WebSite_newContent.xml Fri Aug 25 15:13:04 2006
@@ -1,0 +1,277 @@
+<?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
+  Create New Content by Cloning or Other Methods (replace old WebSite_clone).\n
+"""\n
+\n
+form_data = context.REQUEST.form\n
+context.log(\'WebSite_clone received REQUEST:\', form_data)\n
+\n
+# Here is the list of field name to ignore as property\n
+IGNORED_FORM_ID_LIST = [ \\\n
+                       # don\'t change id, else it would paste & setid in the same transaction.\n
+                         \'id\'\n
+                       # type of creation method\n
+                       , \'document_action_mode\'\n
+                       # input button pointer coordinates\n
+                       , \'x\', \'y\'\n
+                       # custom forms field ids\n
+                       , \'new_portal_type\', \'destination_section\'\n
+]\n
+\n
+directory     = context.restrictedTraverse(context.getRelativeUrl()).getParent()\n
+creation_mode = form_data[\'document_action_mode\']\n
+\n
+\n
+\n
+# Standard cloning method\n
+if creation_mode == \'clone\':\n
+  # TODO ?: If the document language hasn\'t changed and the version wasn\'t increased,\n
+  #           change the copied document reference to "copy-of-%s". This idea came from\n
+  #           the fact some published document are "invisible" because cloned documents\n
+  #           share by default the same reference (within a set of documents of same\n
+  #           references in a given section, only one document is display).\n
+\n
+  #context.log("Kev test context.getId >>>>>", repr(context.getId()))\n
+  #context.log("Kev test directory     >>>>>", repr(directory))\n
+\n
+  # Copy and paste the object\n
+  clipboard    = directory.manage_copyObjects(ids=[context.getId()])\n
+  #context.log("Kev test clipboard                  >>>>>", repr(clipboard))\n
+  paste_result = directory.manage_pasteObjects(cb_copy_data=clipboard)\n
+  new_object   = directory[paste_result[0][\'new_id\']]\n
+\n
+  #context.log("Kev test paste_result               >>>>>", repr(paste_result))\n
+  #context.log("Kev test directory.WebSite_getUrl() >>>>>", repr(directory.WebSite_getUrl()))\n
+  #context.log("Kev test new_object.getId()         >>>>>", repr(new_object.getId()))\n
+\n
+  redirect_url = \'%s/%s/WebPage_view?editable_mode=1\' % (directory.WebSite_getUrl(), new_object.getId())\n
+\n
+\n
+# Kevin\'s easy clone & edit method\n
+elif creation_mode == \'clone_to\':\n
+  # Copy and paste the object\n
+  clipboard    = directory.manage_copyObjects(ids=[context.getId()])\n
+  paste_result = directory.manage_pasteObjects(cb_copy_data=clipboard)\n
+  new_object   = directory[paste_result[0][\'new_id\']]\n
+\n
+  dest_section_url = form_data[\'destination_section\']\n
+\n
+  # Put the cloned document in the right section.\n
+  # Because there is no direct relationship between a web page and its\n
+  #   publication place, we need to randomly determine web page property\n
+  #   value that will match the publishing predicate of the destination\n
+  #   section.\n
+  website_id               = context.WebSite_getSiteValue().getRelativeUrl()\n
+  dest_section_absolut_url = \'%s/%s\' % (website_id, dest_section_url)\n
+  dest_section_object      = context.restrictedTraverse(dest_section_absolut_url)\n
+  criterion_list           = dest_section_object.getMembershipCriterionCategoryList()\n
+\n
+  # Choose a random criterion based on publication_section category\n
+  for criterion in criterion_list:\n
+    if criterion.startswith(\'publication_section/\'):\n
+      new_object.setPublicationSection(criterion[len(\'publication_section/\'):])\n
+      break\n
+\n
+  # Redirect to the edit page of the cloned document in the context of the destination section\n
+  redirect_url = \'%s/%s/%s/WebPage_view?editable_mode=1\' % ( directory.WebSite_getUrl()\n
+                                                           , dest_section_url\n
+                                                           , new_object.getId()\n
+                                                           )\n
+\n
+\n
+# Create a new object here (this is a copy and paste of the previous WebSite_clone script)\n
+else:\n
+  # Get the new object portal type\n
+  new_portal_type = context.REQUEST.form[\'new_portal_type\']\n
+  # Guess the new document module\n
+  portal       = context.getPortalObject()\n
+  module       = portal.getDefaultModule(portal_type=new_portal_type)\n
+  new_object   = module.newContent(portal_type = new_portal_type)\n
+  redirect_url = \'%s/%s/%s/view?editable_mode=1\' % (directory.WebSite_getUrl(), module.getId(), new_object.getId())\n
+\n
+\n
+# Clone properties to the new object\n
+for (key, val) in form_data.items():\n
+  if key not in IGNORED_FORM_ID_LIST and new_object.hasProperty(key):\n
+    context.log(\'WebSite_clone\', \'overwriting attribute "%s" to value "%s"\' % (key, val))\n
+    new_object.setProperty(key, val)\n
+\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></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>form_data</string>
+                            <string>IGNORED_FORM_ID_LIST</string>
+                            <string>directory</string>
+                            <string>_getitem_</string>
+                            <string>creation_mode</string>
+                            <string>clipboard</string>
+                            <string>paste_result</string>
+                            <string>new_object</string>
+                            <string>redirect_url</string>
+                            <string>dest_section_url</string>
+                            <string>website_id</string>
+                            <string>dest_section_absolut_url</string>
+                            <string>dest_section_object</string>
+                            <string>criterion_list</string>
+                            <string>_getiter_</string>
+                            <string>criterion</string>
+                            <string>len</string>
+                            <string>new_portal_type</string>
+                            <string>portal</string>
+                            <string>module</string>
+                            <string>key</string>
+                            <string>val</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>WebSite_newContent</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>




More information about the Erp5-report mailing list