From 9861ce84da996c181f32a4e14e2752e90c49cb0c Mon Sep 17 00:00:00 2001 From: Alexandre Boeglin <alex@nexedi.com> Date: Thu, 10 Apr 2008 09:17:00 +0000 Subject: [PATCH] Add two ParallelListField hash scripts. These two are supposed to be used on all variation related ParallelListField, and thus replace the 3 or 4 hash scripts that already exist. Base_getMultiListFieldPropertyDictList generates MultiListFields dicts Base_getLineListFieldPropertyDictList generates ListFields dicts git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20405 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../Base_getLineListFieldPropertyDictList.xml | 196 +++++++++++++++++ ...Base_getMultiListFieldPropertyDictList.xml | 201 ++++++++++++++++++ product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- 3 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getLineListFieldPropertyDictList.xml create mode 100644 product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getMultiListFieldPropertyDictList.xml diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getLineListFieldPropertyDictList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getLineListFieldPropertyDictList.xml new file mode 100644 index 0000000000..b2451fc783 --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getLineListFieldPropertyDictList.xml @@ -0,0 +1,196 @@ +<?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># Define a dictionary where we store the subfields to display.\n +sub_field_dict = {}\n +split_depth = 1\n +# Try to assign each item to a sub field.\n +for item in item_list:\n + # Get value of the item\n + item_value = item[int(not is_right_display)]\n + # Hash key from item_value\n + item_split = item_value.split(\'/\')\n + item_key = \'/\'.join(item_split[:split_depth])\n + base_category = item_split[0]\n + # Create a new subfield if necessary\n + if not sub_field_dict.has_key(item_key):\n + # Create property dict (key are field parameters)\n + sub_field_property_dict = default_sub_field_property_dict.copy()\n + sub_field_property_dict[\'key\'] = item_key\n + sub_field_property_dict[\'title\'] = context.portal_categories[base_category].getTitle()\n + sub_field_property_dict[\'required\'] = 0\n + sub_field_property_dict[\'field_type\'] = \'ListField\'\n + sub_field_property_dict[\'size\'] = 1\n + sub_field_property_dict[\'item_list\'] = [(\'\', \'\')]\n + sub_field_property_dict[\'value\'] = None\n + sub_field_dict[item_key] = sub_field_property_dict\n + # Put the value in the correct sub field.\n + sub_field_dict[item_key][\'item_list\'].append(item)\n + if item_value in value_list and sub_field_property_dict[\'value\'] is None:\n + sub_field_dict[item_key][\'value\'] = item_value\n +\n +# Return the list of subfield configuration.\n +\n +return sub_field_dict.values()\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>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</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>4</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>item_list</string> + <string>value_list</string> + <string>default_sub_field_property_dict</string> + <string>is_right_display</string> + <string>sub_field_dict</string> + <string>split_depth</string> + <string>_getiter_</string> + <string>item</string> + <string>_getitem_</string> + <string>int</string> + <string>item_value</string> + <string>_getattr_</string> + <string>item_split</string> + <string>item_key</string> + <string>base_category</string> + <string>sub_field_property_dict</string> + <string>_write_</string> + <string>context</string> + <string>None</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <tuple> + <dictionary/> + <int>0</int> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Base_getLineListFieldPropertyDictList</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getMultiListFieldPropertyDictList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getMultiListFieldPropertyDictList.xml new file mode 100644 index 0000000000..469f34942e --- /dev/null +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getMultiListFieldPropertyDictList.xml @@ -0,0 +1,201 @@ +<?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># Define a dictionary where we store the subfields to display.\n +sub_field_dict = {}\n +split_depth = 1\n +# Maximum size of the MultiListField\n +maximum_list_size = 5\n +# Try to assign each item to a sub field.\n +for item in item_list:\n + # Get value of the item\n + item_value = item[int(not is_right_display)]\n + # Hash key from item_value\n + item_split = item_value.split(\'/\')\n + item_key = \'/\'.join(item_split[:split_depth])\n + base_category = item_split[0]\n + # Create a new subfield if necessary\n + if not sub_field_dict.has_key(item_key):\n + # Create property dict (key are field parameters)\n + sub_field_property_dict = default_sub_field_property_dict.copy()\n + sub_field_property_dict[\'key\'] = item_key\n + sub_field_property_dict[\'title\'] = context.portal_categories[base_category].getTitle()\n + sub_field_property_dict[\'required\'] = 0\n + sub_field_property_dict[\'field_type\'] = \'MultiListField\'\n + sub_field_property_dict[\'size\'] = 1\n + sub_field_property_dict[\'item_list\'] = []\n + sub_field_property_dict[\'value\'] = []\n + sub_field_dict[item_key] = sub_field_property_dict\n + # Put the value in the correct sub field.\n + sub_field_dict[item_key][\'item_list\'].append(item)\n + sub_field_property_dict[\'size\'] = min(len(sub_field_dict[item_key][\'item_list\']) , maximum_list_size )\n + if item_value in value_list:\n + sub_field_dict[item_key][\'value\'].append(item_value)\n +\n +# Return the list of subfield configuration.\n +\n +return sub_field_dict.values()\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>item_list, value_list, default_sub_field_property_dict={}, is_right_display=0</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>4</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>item_list</string> + <string>value_list</string> + <string>default_sub_field_property_dict</string> + <string>is_right_display</string> + <string>sub_field_dict</string> + <string>split_depth</string> + <string>maximum_list_size</string> + <string>_getiter_</string> + <string>item</string> + <string>_getitem_</string> + <string>int</string> + <string>item_value</string> + <string>_getattr_</string> + <string>item_split</string> + <string>item_key</string> + <string>base_category</string> + <string>sub_field_property_dict</string> + <string>_write_</string> + <string>context</string> + <string>min</string> + <string>len</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <tuple> + <dictionary/> + <int>0</int> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Base_getMultiListFieldPropertyDictList</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index d0af645045..83249da5a1 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -783 \ No newline at end of file +784 \ No newline at end of file -- 2.30.9