From a0ce2d98a7302b91420663fc26986172f4dbc883 Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Thu, 14 Oct 2010 08:45:21 +0000 Subject: [PATCH] Separate script to get duplicating selection names and improve it. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39119 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../SkinsTool_checkDuplicateSelectionName.xml | 25 +-- ...kinsTool_getDuplicateSelectionNameDict.xml | 157 ++++++++++++++++++ bt5/erp5_forge/bt/revision | 2 +- 3 files changed, 162 insertions(+), 22 deletions(-) create mode 100644 bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getDuplicateSelectionNameDict.xml diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_checkDuplicateSelectionName.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_checkDuplicateSelectionName.xml index f52c8528fa..47b454d752 100644 --- a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_checkDuplicateSelectionName.xml +++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_checkDuplicateSelectionName.xml @@ -2,10 +2,7 @@ <ZopeData> <record id="1" aka="AAAAAAAAAAE="> <pickle> - <tuple> - <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> - <tuple/> - </tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> </pickle> <pickle> <dictionary> @@ -55,21 +52,11 @@ <key> <string>_body</string> </key> <value> <string encoding="cdata"><![CDATA[ -"""Print all listbox that uses the same selection name.\n """\n -skins_tool = context.portal_skins\n -selection_name_dict = dict()\n -\n -for field_path, field in skins_tool.ZopeFind(\n - skins_tool, obj_metatypes=[\'ProxyField\', \'ListBox\'], search_sub=1):\n - if field.meta_type == \'ProxyField\':\n - if field.getRecursiveTemplateField().meta_type != \'ListBox\' \\\n - or field.is_delegated(\'selection_name\'):\n - continue\n - \n - selection_name_dict.setdefault(\n - field.get_value(\'selection_name\'), []).append(field_path)\n + Print all listbox that uses the same selection name.\n +"""\n \n +selection_name_dict = context.SkinsTool_getDuplicateSelectionNameDict()\n for selection_name, field_list in selection_name_dict.items():\n if len(field_list) > 1:\n print repr(selection_name), \'\\n\\t\', \'\\n\\t\'.join(field_list)\n @@ -116,12 +103,8 @@ return printed\n <string>_print</string> <string>_getattr_</string> <string>context</string> - <string>skins_tool</string> - <string>dict</string> <string>selection_name_dict</string> <string>_getiter_</string> - <string>field_path</string> - <string>field</string> <string>selection_name</string> <string>field_list</string> <string>len</string> diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getDuplicateSelectionNameDict.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getDuplicateSelectionNameDict.xml new file mode 100644 index 0000000000..6934889a73 --- /dev/null +++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getDuplicateSelectionNameDict.xml @@ -0,0 +1,157 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </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 + Get all listbox fields that uses the same selection name.\n +"""\n +\n +skins_tool = context.portal_skins\n +selection_name_dict = {}\n +\n +ok_to_share_selection_form_list = [\'Resource_viewInventory\', \'Resource_viewMovementHistory\']\n +\n +for field_path, field in skins_tool.ZopeFind(\n + skins_tool, obj_metatypes=[\'ProxyField\', \'ListBox\'], search_sub=1):\n + form = field.aq_parent\n + if field.meta_type == \'ProxyField\':\n + original_field = field.getRecursiveTemplateField()\n + if original_field is not None and \\\n + (original_field.meta_type != \'ListBox\' \\\n + or field.is_delegated(\'selection_name\')\n + or original_field.get_tales(\'selection_name\')!=\'\'):\n + continue\n + elif field.meta_type == \'ListBox\':\n + if field.get_tales(\'selection_name\')!=\'\':\n + continue\n + # in some rare cases sharing a selection can be done intentional so avoid them\n + if form.getId() in ok_to_share_selection_form_list:\n + continue\n +\n + selection_name_dict.setdefault(\n + field.get_value(\'selection_name\'), []).append(field_path)\n +\n +return selection_name_dict\n +</string> </value> + </item> + <item> + <key> <string>_code</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>skins_tool</string> + <string>selection_name_dict</string> + <string>ok_to_share_selection_form_list</string> + <string>_getiter_</string> + <string>field_path</string> + <string>field</string> + <string>form</string> + <string>original_field</string> + <string>None</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>SkinsTool_getDuplicateSelectionNameDict</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_forge/bt/revision b/bt5/erp5_forge/bt/revision index 633fa34c7f..ca6d18c238 100644 --- a/bt5/erp5_forge/bt/revision +++ b/bt5/erp5_forge/bt/revision @@ -1 +1 @@ -615 \ No newline at end of file +616 \ No newline at end of file -- 2.30.9