From 695f6ec2b434728b8cbc7bf9b0dc6d51485fe889 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 22 Oct 2007 09:31:47 +0000
Subject: [PATCH] 2007-10-22 Jerome * Added two utility scripts
 SkinsTool_checkDuplicateSelectionName and SkinsTool_getNotAssignedFieldList
 in erp5_toolbox

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17081 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../SkinsTool_checkDuplicateSelectionName.xml | 180 ++++++++++++++++++
 .../SkinsTool_getNotAssignedFieldList.xml     | 171 +++++++++++++++++
 bt5/erp5_forge/bt/change_log                  |   3 +
 bt5/erp5_forge/bt/revision                    |   2 +-
 bt5/erp5_forge/bt/template_tool_id_list       |   0
 5 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_checkDuplicateSelectionName.xml
 create mode 100644 bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getNotAssignedFieldList.xml
 create mode 100644 bt5/erp5_forge/bt/template_tool_id_list

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
new file mode 100644
index 0000000000..992f7b02f7
--- /dev/null
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_checkDuplicateSelectionName.xml
@@ -0,0 +1,180 @@
+<?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 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
+\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
+return printed\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></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>_print_</string>
+                            <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>
+                            <string>repr</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_checkDuplicateSelectionName</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getNotAssignedFieldList.xml b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getNotAssignedFieldList.xml
new file mode 100644
index 0000000000..81f77f6268
--- /dev/null
+++ b/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/SkinsTool_getNotAssignedFieldList.xml
@@ -0,0 +1,171 @@
+<?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>"""Prints all fields that are in \'not assigned\' group.\n
+This happens after updating a form where some fields have been added locally.\n
+"""\n
+\n
+for form_path, form in context.ZopeFind(\n
+            context.portal_skins, obj_metatypes=[\'ERP5 Form\'], search_sub=1):\n
+  try:\n
+    groups = form.get_groups()\n
+  except AttributeError, e:\n
+    print "%s is broken: %s" % (form_path, e)\n
+  if \'not_assigned\' in groups:\n
+    print \'Not assigned fields in %s: %s\' % (form_path,\n
+      [f.getId() for f in form.get_fields_in_group(\'not_assigned\')])\n
+\n
+return printed\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></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>_print_</string>
+                            <string>_print</string>
+                            <string>_getiter_</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>form_path</string>
+                            <string>form</string>
+                            <string>groups</string>
+                            <string>AttributeError</string>
+                            <string>e</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>f</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_getNotAssignedFieldList</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_forge/bt/change_log b/bt5/erp5_forge/bt/change_log
index 65dc9064cf..f8fcb58f1f 100644
--- a/bt5/erp5_forge/bt/change_log
+++ b/bt5/erp5_forge/bt/change_log
@@ -1,3 +1,6 @@
+2007-10-22 Jerome
+* Added two utility scripts SkinsTool_checkDuplicateSelectionName and SkinsTool_getNotAssignedFieldList in erp5_toolbox
+
 2007-08-14 Yusei
 * Add utility scripts to collect translation messages.
 
diff --git a/bt5/erp5_forge/bt/revision b/bt5/erp5_forge/bt/revision
index a3090d211b..9a1371776c 100644
--- a/bt5/erp5_forge/bt/revision
+++ b/bt5/erp5_forge/bt/revision
@@ -1 +1 @@
-168
\ No newline at end of file
+169
\ No newline at end of file
diff --git a/bt5/erp5_forge/bt/template_tool_id_list b/bt5/erp5_forge/bt/template_tool_id_list
new file mode 100644
index 0000000000..e69de29bb2
-- 
2.30.9