Commit a0ce2d98 authored by Ivan Tyagov's avatar Ivan Tyagov

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
parent 3b117a2a
...@@ -2,10 +2,7 @@ ...@@ -2,10 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -55,21 +52,11 @@ ...@@ -55,21 +52,11 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
"""Print all listbox that uses the same selection name.\n
"""\n """\n
skins_tool = context.portal_skins\n Print all listbox that uses the same selection name.\n
selection_name_dict = dict()\n """\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
\n \n
selection_name_dict = context.SkinsTool_getDuplicateSelectionNameDict()\n
for selection_name, field_list in selection_name_dict.items():\n for selection_name, field_list in selection_name_dict.items():\n
if len(field_list) > 1:\n if len(field_list) > 1:\n
print repr(selection_name), \'\\n\\t\', \'\\n\\t\'.join(field_list)\n print repr(selection_name), \'\\n\\t\', \'\\n\\t\'.join(field_list)\n
...@@ -116,12 +103,8 @@ return printed\n ...@@ -116,12 +103,8 @@ return printed\n
<string>_print</string> <string>_print</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>skins_tool</string>
<string>dict</string>
<string>selection_name_dict</string> <string>selection_name_dict</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>field_path</string>
<string>field</string>
<string>selection_name</string> <string>selection_name</string>
<string>field_list</string> <string>field_list</string>
<string>len</string> <string>len</string>
......
<?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>
615 616
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment