Commit d078c17d authored by Vincent Pelletier's avatar Vincent Pelletier

Implement erp5_web API.

Remove useless pythons scripts (related to a specific use of erp5_web).
Fix WebSite_createContent.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6105 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cca33e8d
<local_roles_item>
<local_roles>
<role id='jp'>
<role id='vincent'>
<item>Owner</item>
</role>
</local_roles>
......
......@@ -19,9 +19,6 @@
<permission>
<name>Access session data</name>
</permission>
<permission>
<name>AccessContentsInformation</name>
</permission>
<permission>
<name>Add Accelerated HTTP Cache Managers</name>
</permission>
......@@ -29,10 +26,10 @@
<name>Add BTreeFolder2s</name>
</permission>
<permission>
<name>Add Base18 Tools</name>
<name>Add Browser Id Manager</name>
</permission>
<permission>
<name>Add Browser Id Manager</name>
<name>Add CMF Action Icons Tools</name>
</permission>
<permission>
<name>Add CMF Active Processs</name>
......@@ -40,32 +37,38 @@
<permission>
<name>Add CMF Caching Policy Managers</name>
</permission>
<permission>
<name>Add CMF Calendar Tools</name>
</permission>
<permission>
<name>Add CMF Core Tools</name>
</permission>
<permission>
<name>Add CMF Default Tools</name>
</permission>
<permission>
<name>Add CMF Report Tools</name>
</permission>
<permission>
<name>Add CMF Sites</name>
<name>Add CMF Setup Tools</name>
</permission>
<permission>
<name>Add CMFActivity Tools</name>
<name>Add CMF Sites</name>
</permission>
<permission>
<name>Add CMFCalendar Tools</name>
<name>Add CMF Unique Id Tools</name>
</permission>
<permission>
<name>Add CMFCategory Tools</name>
<name>Add CMFActivity Tools</name>
</permission>
<permission>
<name>Add CMFDefault Tools</name>
<name>Add CMFCategory Tools</name>
</permission>
<permission>
<name>Add CMFMailIn Tools</name>
</permission>
<permission>
<name>Add CMFWiki Comment</name>
<name>Add Configured CMF Sites</name>
</permission>
<permission>
<name>Add Content Type Registrys</name>
......@@ -115,9 +118,6 @@
<permission>
<name>Add ERP5Form Tools</name>
</permission>
<permission>
<name>Add ERP5Shop Tools</name>
</permission>
<permission>
<name>Add ERP5SyncML Tools</name>
</permission>
......@@ -151,9 +151,6 @@
<permission>
<name>Add Localizers</name>
</permission>
<permission>
<name>Add MMM Shop Toolss</name>
</permission>
<permission>
<name>Add MailHost objects</name>
</permission>
......@@ -173,7 +170,7 @@
<name>Add Pluggable Index</name>
</permission>
<permission>
<name>Add Portal ZSyncer Tools</name>
<name>Add Plugin Registrys</name>
</permission>
<permission>
<name>Add Python Scripts</name>
......@@ -226,9 +223,6 @@
<permission>
<name>Add ZODB Mount Points</name>
</permission>
<permission>
<name>Add ZSyncers</name>
</permission>
<permission>
<name>Add Zope Tutorials</name>
</permission>
......@@ -247,15 +241,9 @@
<permission>
<name>Add portal topics</name>
</permission>
<permission>
<name>Add shop category</name>
</permission>
<permission>
<name>Change Browser Id Manager</name>
</permission>
<permission>
<name>Change CMFWiki Regulations</name>
</permission>
<permission>
<name>Change DTML Documents</name>
</permission>
......@@ -319,6 +307,9 @@
<permission>
<name>Change configuration</name>
</permission>
<permission>
<name>Change local roles</name>
</permission>
<permission>
<name>Change permissions</name>
</permission>
......@@ -331,15 +322,9 @@
<permission>
<name>Change proxy roles</name>
</permission>
<permission>
<name>Checkout shopping cart</name>
</permission>
<permission>
<name>Copy or Move</name>
</permission>
<permission>
<name>Create CMFWiki Page</name>
</permission>
<permission>
<name>Create Transient Objects</name>
</permission>
......@@ -355,12 +340,6 @@
<permission>
<name>Download ExtFile/ExtImage</name>
</permission>
<permission>
<name>Download Product</name>
</permission>
<permission>
<name>Edit CMFWiki Page</name>
</permission>
<permission>
<name>Edit Factories</name>
</permission>
......@@ -397,9 +376,15 @@
<permission>
<name>Manage Access Rules</name>
</permission>
<permission>
<name>Manage Groups</name>
</permission>
<permission>
<name>Manage Transient Object Container</name>
</permission>
<permission>
<name>Manage Translation Services</name>
</permission>
<permission>
<name>Manage Vocabulary</name>
</permission>
......@@ -415,12 +400,6 @@
<permission>
<name>Manage ZCatalogIndex Entries</name>
</permission>
<permission>
<name>Manage currencies</name>
</permission>
<permission>
<name>Manage extensions</name>
</permission>
<permission>
<name>Manage languages</name>
</permission>
......@@ -433,30 +412,15 @@
<permission>
<name>Manage properties</name>
</permission>
<permission>
<name>Manage shop</name>
</permission>
<permission>
<name>Manage shop catalog</name>
</permission>
<permission>
<name>Manage shop category</name>
</permission>
<permission>
<name>Manage users</name>
</permission>
<permission>
<name>Manage_messages</name>
</permission>
<permission>
<name>Modify Cookie Crumblers</name>
</permission>
<permission>
<name>Modify portal content</name>
</permission>
<permission>
<name>Move CMFWiki Page</name>
</permission>
<permission>
<name>Open/Close Database Connection</name>
</permission>
......@@ -484,6 +448,9 @@
<permission>
<name>Search ZCatalog</name>
</permission>
<permission>
<name>Search for principals</name>
</permission>
<permission>
<name>Set own password</name>
</permission>
......@@ -532,15 +499,6 @@
<permission>
<name>WebDAV access</name>
</permission>
<permission>
<name>ZSyncer: Use ZSyncer</name>
</permission>
<permission>
<name>ZopeProfiler: manage</name>
</permission>
<permission>
<name>ZopeProfiler: view</name>
</permission>
</permission_list>
<portal_type>Web Page Module</portal_type>
<title>Web Pages</title>
......
......@@ -19,9 +19,6 @@
<permission>
<name>Access session data</name>
</permission>
<permission>
<name>AccessContentsInformation</name>
</permission>
<permission>
<name>Add Accelerated HTTP Cache Managers</name>
</permission>
......@@ -29,10 +26,10 @@
<name>Add BTreeFolder2s</name>
</permission>
<permission>
<name>Add Base18 Tools</name>
<name>Add Browser Id Manager</name>
</permission>
<permission>
<name>Add Browser Id Manager</name>
<name>Add CMF Action Icons Tools</name>
</permission>
<permission>
<name>Add CMF Active Processs</name>
......@@ -40,32 +37,38 @@
<permission>
<name>Add CMF Caching Policy Managers</name>
</permission>
<permission>
<name>Add CMF Calendar Tools</name>
</permission>
<permission>
<name>Add CMF Core Tools</name>
</permission>
<permission>
<name>Add CMF Default Tools</name>
</permission>
<permission>
<name>Add CMF Report Tools</name>
</permission>
<permission>
<name>Add CMF Sites</name>
<name>Add CMF Setup Tools</name>
</permission>
<permission>
<name>Add CMFActivity Tools</name>
<name>Add CMF Sites</name>
</permission>
<permission>
<name>Add CMFCalendar Tools</name>
<name>Add CMF Unique Id Tools</name>
</permission>
<permission>
<name>Add CMFCategory Tools</name>
<name>Add CMFActivity Tools</name>
</permission>
<permission>
<name>Add CMFDefault Tools</name>
<name>Add CMFCategory Tools</name>
</permission>
<permission>
<name>Add CMFMailIn Tools</name>
</permission>
<permission>
<name>Add CMFWiki Comment</name>
<name>Add Configured CMF Sites</name>
</permission>
<permission>
<name>Add Content Type Registrys</name>
......@@ -115,9 +118,6 @@
<permission>
<name>Add ERP5Form Tools</name>
</permission>
<permission>
<name>Add ERP5Shop Tools</name>
</permission>
<permission>
<name>Add ERP5SyncML Tools</name>
</permission>
......@@ -151,9 +151,6 @@
<permission>
<name>Add Localizers</name>
</permission>
<permission>
<name>Add MMM Shop Toolss</name>
</permission>
<permission>
<name>Add MailHost objects</name>
</permission>
......@@ -173,7 +170,7 @@
<name>Add Pluggable Index</name>
</permission>
<permission>
<name>Add Portal ZSyncer Tools</name>
<name>Add Plugin Registrys</name>
</permission>
<permission>
<name>Add Python Scripts</name>
......@@ -226,9 +223,6 @@
<permission>
<name>Add ZODB Mount Points</name>
</permission>
<permission>
<name>Add ZSyncers</name>
</permission>
<permission>
<name>Add Zope Tutorials</name>
</permission>
......@@ -247,15 +241,9 @@
<permission>
<name>Add portal topics</name>
</permission>
<permission>
<name>Add shop category</name>
</permission>
<permission>
<name>Change Browser Id Manager</name>
</permission>
<permission>
<name>Change CMFWiki Regulations</name>
</permission>
<permission>
<name>Change DTML Documents</name>
</permission>
......@@ -319,6 +307,9 @@
<permission>
<name>Change configuration</name>
</permission>
<permission>
<name>Change local roles</name>
</permission>
<permission>
<name>Change permissions</name>
</permission>
......@@ -331,15 +322,9 @@
<permission>
<name>Change proxy roles</name>
</permission>
<permission>
<name>Checkout shopping cart</name>
</permission>
<permission>
<name>Copy or Move</name>
</permission>
<permission>
<name>Create CMFWiki Page</name>
</permission>
<permission>
<name>Create Transient Objects</name>
</permission>
......@@ -355,12 +340,6 @@
<permission>
<name>Download ExtFile/ExtImage</name>
</permission>
<permission>
<name>Download Product</name>
</permission>
<permission>
<name>Edit CMFWiki Page</name>
</permission>
<permission>
<name>Edit Factories</name>
</permission>
......@@ -397,9 +376,15 @@
<permission>
<name>Manage Access Rules</name>
</permission>
<permission>
<name>Manage Groups</name>
</permission>
<permission>
<name>Manage Transient Object Container</name>
</permission>
<permission>
<name>Manage Translation Services</name>
</permission>
<permission>
<name>Manage Vocabulary</name>
</permission>
......@@ -415,12 +400,6 @@
<permission>
<name>Manage ZCatalogIndex Entries</name>
</permission>
<permission>
<name>Manage currencies</name>
</permission>
<permission>
<name>Manage extensions</name>
</permission>
<permission>
<name>Manage languages</name>
</permission>
......@@ -433,30 +412,15 @@
<permission>
<name>Manage properties</name>
</permission>
<permission>
<name>Manage shop</name>
</permission>
<permission>
<name>Manage shop catalog</name>
</permission>
<permission>
<name>Manage shop category</name>
</permission>
<permission>
<name>Manage users</name>
</permission>
<permission>
<name>Manage_messages</name>
</permission>
<permission>
<name>Modify Cookie Crumblers</name>
</permission>
<permission>
<name>Modify portal content</name>
</permission>
<permission>
<name>Move CMFWiki Page</name>
</permission>
<permission>
<name>Open/Close Database Connection</name>
</permission>
......@@ -484,6 +448,9 @@
<permission>
<name>Search ZCatalog</name>
</permission>
<permission>
<name>Search for principals</name>
</permission>
<permission>
<name>Set own password</name>
</permission>
......@@ -532,15 +499,6 @@
<permission>
<name>WebDAV access</name>
</permission>
<permission>
<name>ZSyncer: Use ZSyncer</name>
</permission>
<permission>
<name>ZopeProfiler: manage</name>
</permission>
<permission>
<name>ZopeProfiler: view</name>
</permission>
</permission_list>
<portal_type>Web Site Module</portal_type>
<title>Web Sites</title>
......
......@@ -26,7 +26,7 @@
</item>
<item>
<key> <string>connection_string</string> </key>
<value> <string>erp5 erp5 erp5</string> </value>
<value> <string>website2 erp5 erp5</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -565,7 +565,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>WebSite_getDocumentList</string> </value>
<value> <string>WebSite_getDocumentValueList</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value> <string encoding="base64">O/INCg==</string> </value>
<value> <string encoding="base64">bfINCg==</string> </value>
</item>
<item>
<key> <string>Script_magic</string> </key>
......@@ -66,29 +66,27 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if create or duplicate:\n
type_name=\'Web Page\'\n
else:\n
<value> <string>portal_type = context.getPortalType()\n
if portal_type not in (\'Web Page\', \'Web Section\'):\n
context.log(\'WebSite_createContent\', \'Unable to clone type %s. Nothing done.\' % type_name)\n
return\n
\n
request = context.REQUEST\n
\n
module = context.getDefaultModule(portal_type=type_name)\n
module = context.getDefaultModule(portal_type=portal_type)\n
new_id = module.generateNewId()\n
new_content = module.newContent(portal_type=type_name,\n
new_content = module.newContent(portal_type=portal_type,\n
container=module,\n
id=str(new_id))\n
new_content.setCategories(context.getCategories())\n
new_content.setReference(reference)\n
new_content.setTitle(title)\n
new_content.setShortTitle(short_title)\n
new_content.setVersion(version)\n
#new_content.setLanguage(language)\n
if duplicate:\n
new_content.setTextContent(context.getTextContent())\n
new_content.setLanguage(language)\n
new_content.setTextContent(context.getTextContent())\n
\n
#redirect_url = new_content.WebSite_getDocumentUrl()\n
redirect_url = "%s/%s" % (request.URL2,new_content.getReference())\n
redirect_url = new_content.WebSite_getDocumentUrl()\n
context.log(\'WebSite_createContent\',\'redirect_url = %s\' % redirect_url)\n
return request.RESPONSE.redirect( redirect_url )\n
</string> </value>
</item>
......@@ -100,7 +98,7 @@ return request.RESPONSE.redirect( redirect_url )\n
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_web/WebSite_createContent</string> </value>
<value> <string>Script (Python):/erp5/portal_skins/erp5_web/WebSite_createContent</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
......@@ -110,7 +108,7 @@ return request.RESPONSE.redirect( redirect_url )\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference=\'\', version=\'\', language=\'\', title=\'\', short_title=\'\', create=None, duplicate=None</string> </value>
<value> <string>parent_url=\'\', reference=\'\', version=\'\', language=\'\', short_title=\'\'</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -130,22 +128,21 @@ return request.RESPONSE.redirect( redirect_url )\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>7</int> </value>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>parent_url</string>
<string>reference</string>
<string>version</string>
<string>language</string>
<string>title</string>
<string>short_title</string>
<string>create</string>
<string>duplicate</string>
<string>type_name</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_type</string>
<string>type_name</string>
<string>request</string>
<string>module</string>
<string>new_id</string>
......@@ -169,8 +166,6 @@ return request.RESPONSE.redirect( redirect_url )\n
<string></string>
<string></string>
<string></string>
<none/>
<none/>
</tuple>
</value>
</item>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value> <string encoding="base64">O/INCg==</string> </value>
<value> <string encoding="base64">bfINCg==</string> </value>
</item>
<item>
<key> <string>Script_magic</string> </key>
......@@ -68,23 +68,16 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
current_section = context\n
if current_section.getPortalType() in (\'Web Site\', \'Web Section\'):\n
breadcrumb_list = []\n
else:\n
breadcrumb_list = [\'<a href="%s">%s</a>\' % (current_section.WebSite_getDocumentUrl(), current_section.getTitle())]\n
while current_section is not None and current_section.getPortalType() != \'Web Site\':\n
if current_section.getPortalType() == \'Web Section\':\n
breadcrumb_list.append(\'<a href="%s">%s</a>\' % (current_section.WebSite_getDocumentUrl(), current_section.getTitle()))\n
previous_section = current_section\n
current_section = current_section.getParent()\n
html_list = []\n
\n
if current_section.getPortalType() == \'Web Site\':\n
breadcrumb_list.append(\'<a href="%s">%s</a>\' % (current_section.WebSite_getDocumentUrl(), current_section.getTitle()))\n
for crumb in context.WebSite_getBreadcrumbValue():\n
if crumb.getTitle() is None or crumb.getTitle() == \'\':\n
text = crumb.getId()\n
else:\n
text = crumb.getTitle()\n
html_list.append(\'<a href="%s">%s</a>\' % (crumb.WebSite_getUrl(), text))\n
\n
breadcrumb_list.reverse()\n
\n
return \' &gt; \'.join(breadcrumb_list)\n
return \' &gt; \'.join(html_list)\n
]]></string> </value>
......@@ -97,7 +90,7 @@ return \' &gt; \'.join(breadcrumb_list)\n
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_web/WebSite_getBreadcrumb</string> </value>
<value> <string>Script (Python):/erp5/portal_skins/erp5_web/WebSite_getBreadcrumb</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......@@ -127,12 +120,13 @@ return \' &gt; \'.join(breadcrumb_list)\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>context</string>
<string>current_section</string>
<string>html_list</string>
<string>_getiter_</string>
<string>_getattr_</string>
<string>breadcrumb_list</string>
<string>context</string>
<string>crumb</string>
<string>None</string>
<string>previous_section</string>
<string>text</string>
</tuple>
</value>
</item>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value> <string encoding="base64">O/INCg==</string> </value>
<value> <string encoding="base64">bfINCg==</string> </value>
</item>
<item>
<key> <string>Script_magic</string> </key>
......@@ -66,18 +66,19 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>current_section = context\n
if current_section.getPortalType() == \'Web Section\':\n
previous_section = current_section\n
else:\n
previous_section = None\n
while current_section is not None and current_section.getPortalType() != \'Web Site\':\n
if current_section.getPortalType() == \'Web Section\':\n
previous_section = current_section\n
current_section = current_section.getParent()\n
<value> <string>crumb = context\n
crumb_list = []\n
\n
section_list = current_section.objectValues(portal_type = \'Web Section\', sort_on=\'int_index\')\n
return filter(lambda x: x.isVisible(), section_list)\n
while hasattr(crumb,\'getPortalType\'):\n
crumb_list.append(crumb)\n
if crumb.getPortalType() == \'Web Site\':\n
crumb = None # Don\'t go higher than the first Web Site found\n
else:\n
crumb = crumb.getParent()\n
\n
crumb_list.reverse()\n
\n
return crumb_list\n
</string> </value>
</item>
<item>
......@@ -88,7 +89,13 @@ return filter(lambda x: x.isVisible(), section_list)\n
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_web/WebSite_getMainSectionList</string> </value>
<value> <string>Script (Python):/erp5/portal_skins/erp5_web/WebSite_getBreadcrumbValue</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
......@@ -119,12 +126,11 @@ return filter(lambda x: x.isVisible(), section_list)\n
<value>
<tuple>
<string>context</string>
<string>current_section</string>