[Erp5-report] r10112 - /erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widg...
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Sep 18 17:59:00 CEST 2006
Author: kevin
Date: Mon Sep 18 17:58:59 2006
New Revision: 10112
URL: http://svn.erp5.org?rev=10112&view=rev
Log:
Moved outside the admin_toolbox dedicated folder.
Add a title to descibe the current status of the script.
Added:
erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_newContent.xml
Added: erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_newContent.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_newContent.xml?rev=10112&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_newContent.xml (added)
+++ erp5/trunk/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_newContent.xml Mon Sep 18 17:58:59 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>Clone or Create new content</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