[Erp5-report] r20887 - in /experimental/bt5/erp5_collection_experimental: SkinTemplateItem/...
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue May 6 18:22:07 CEST 2008
Author: bartek
Date: Tue May 6 18:22:03 2008
New Revision: 20887
URL: http://svn.erp5.org?rev=20887&view=rev
Log:
some refactoring to make API cleaner
Added:
experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_addObject.xml
experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_doRemoveObject.xml
Modified:
experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Base_addToCollection.xml
experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_list/listbox_remove_url.xml
experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_removeObject.xml
experimental/bt5/erp5_collection_experimental/bt/revision
Modified: experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Base_addToCollection.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Base_addToCollection.xml?rev=20887&r1=20886&r2=20887&view=diff
==============================================================================
--- experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Base_addToCollection.xml (original)
+++ experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Base_addToCollection.xml Tue May 6 18:22:03 2008
@@ -66,9 +66,9 @@
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
- Add context to selected collection, first make sure\n
- it is not already there.\n
+ Add context to selected collection.\n
"""\n
+\n
N_ = context.Base_translateString\n
\n
def redirect(msg, form_id=None):\n
@@ -89,12 +89,9 @@
if collection is None:\n
return redirect(\'This collection does not exist or is not valid\')\n
\n
-url_list = collection.getCollectionList()\n
-if url in url_list:\n
+result = collection.Collection_addObject(relative_url=url)\n
+if not result:\n
return redirect(\'This object already is in the selected collection\')\n
-\n
-url_list.append(url)\n
-collection.setCollectionList(url_list)\n
return redirect(\'Object added to collection\', \'view\')\n
</string> </value>
</item>
@@ -148,7 +145,7 @@
<string>req</string>
<string>collection</string>
<string>url</string>
- <string>url_list</string>
+ <string>result</string>
</tuple>
</value>
</item>
Added: experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_addObject.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_addObject.xml?rev=20887&view=auto
==============================================================================
--- experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_addObject.xml (added)
+++ experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_addObject.xml Tue May 6 18:22:03 2008
@@ -1,0 +1,165 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+ <tuple/>
+ </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
+ Add object to Collection while checking uniqueness\n
+"""\n
+\n
+if object is None and relative_url is None:\n
+ raise Exception("Needs object or url")\n
+\n
+if relative_url is None:\n
+ relative_url = object.getRelativeUrl()\n
+\n
+url_list = context.getCollectionList()\n
+if relative_url in url_list:\n
+ return False\n
+url_list.append(relative_url)\n
+context.setCollectionList(url_list)\n
+return True\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>object=None, relative_url=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>2</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>object</string>
+ <string>relative_url</string>
+ <string>None</string>
+ <string>Exception</string>
+ <string>_getattr_</string>
+<string>context</string>
+ <string>url_list</string>
+ <string>False</string>
+ <string>True</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <tuple>
+ <none/>
+ <none/>
+ </tuple>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>Collection_addObject</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Added: experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_doRemoveObject.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_doRemoveObject.xml?rev=20887&view=auto
==============================================================================
--- experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_doRemoveObject.xml (added)
+++ experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_doRemoveObject.xml Tue May 6 18:22:03 2008
@@ -1,0 +1,158 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+ <tuple/>
+ </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
+ Management method for removing object from a Collection\n
+"""\n
+\n
+N_ = context.Base_translateString\n
+\n
+res = context.Collection_removeObject(relative_url=relative_url)\n
+if not res:\n
+ msg = N_(\'Could not remove %s from collection\') % relative_url\n
+else:\n
+ msg = N_(\'Remove %s from collection\') % relative_url\n
+\n
+return context.Base_redirect(form_id, keep_items=dict(portal_status_message=msg))\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>relative_url, form_id</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>relative_url</string>
+ <string>form_id</string>
+ <string>_getattr_</string>
+ <string>context</string>
+ <string>N_</string>
+ <string>res</string>
+ <string>msg</string>
+ <string>dict</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>Collection_doRemoveObject</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_list/listbox_remove_url.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_list/listbox_remove_url.xml?rev=20887&r1=20886&r2=20887&view=diff
==============================================================================
--- experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_list/listbox_remove_url.xml (original)
+++ experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_list/listbox_remove_url.xml Tue May 6 18:22:03 2008
@@ -317,7 +317,7 @@
<key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[
-python: \'Collection_removeObject?relative_url=%s&form_id=%s\' % (cell.getRelativeUrl(), \'Collection_list\')
+python: \'Collection_doRemoveObject?relative_url=%s&form_id=%s\' % (cell.getRelativeUrl(), \'Collection_list\')
]]></string> </value>
</item>
Modified: experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_removeObject.xml
URL: http://svn.erp5.org/experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_removeObject.xml?rev=20887&r1=20886&r2=20887&view=diff
==============================================================================
--- experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_removeObject.xml (original)
+++ experimental/bt5/erp5_collection_experimental/SkinTemplateItem/portal_skins/erp5_collection_experimental/Collection_removeObject.xml Tue May 6 18:22:03 2008
@@ -66,22 +66,23 @@
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
- Remove one object from a collection\n
+ API method for removing object from a Collection\n
"""\n
\n
-N_ = context.Base_translateString\n
+if object is None and relative_url is None:\n
+ raise Exception("Needs object or url")\n
+if relative_url is None:\n
+ relative_url = object.getRelativeUrl()\n
\n
collection_list = context.getCollectionList()\n
\n
try:\n
collection_list.remove(relative_url)\n
except ValueError:\n
- msg = N_(\'Could not remove %s from collection\') % relative_url\n
+ return False\n
else:\n
context.setCollectionList(collection_list)\n
- msg = N_(\'Remove %s from collection\') % relative_url\n
-\n
-return context.Base_redirect(form_id, keep_items=dict(portal_status_message=msg))\n
+ return True\n
</string> </value>
</item>
<item>
@@ -98,7 +99,7 @@
</item>
<item>
<key> <string>_params</string> </key>
- <value> <string>relative_url, form_id</string> </value>
+ <value> <string>object=None, relative_url=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
@@ -124,15 +125,16 @@
<key> <string>co_varnames</string> </key>
<value>
<tuple>
+ <string>object</string>
<string>relative_url</string>
- <string>form_id</string>
+ <string>None</string>
+ <string>Exception</string>
<string>_getattr_</string>
<string>context</string>
- <string>N_</string>
<string>collection_list</string>
<string>ValueError</string>
- <string>msg</string>
- <string>dict</string>
+ <string>False</string>
+ <string>True</string>
</tuple>
</value>
</item>
@@ -144,7 +146,10 @@
<item>
<key> <string>func_defaults</string> </key>
<value>
- <none/>
+ <tuple>
+ <none/>
+ <none/>
+ </tuple>
</value>
</item>
<item>
Modified: experimental/bt5/erp5_collection_experimental/bt/revision
URL: http://svn.erp5.org/experimental/bt5/erp5_collection_experimental/bt/revision?rev=20887&r1=20886&r2=20887&view=diff
==============================================================================
--- experimental/bt5/erp5_collection_experimental/bt/revision (original)
+++ experimental/bt5/erp5_collection_experimental/bt/revision Tue May 6 18:22:03 2008
@@ -1,1 +1,1 @@
-1
+3
More information about the Erp5-report
mailing list