From 7488333ee118268802be7b7fa2c4cdf5d57b592e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 29 Jun 2006 13:31:35 +0000
Subject: [PATCH] getCellRangeItemList scripts are not used, asCellRange called
 with matrixbox=1 is a preferred way.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8224 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_payroll/PaySheetLine_asCellRange.xml |  38 ++--
 .../PaySheetLine_getCellRangeItemList.xml     | 178 ------------------
 2 files changed, 21 insertions(+), 195 deletions(-)
 delete mode 100644 bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_getCellRangeItemList.xml

diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_asCellRange.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_asCellRange.xml
index f7a116830c..19bcae179e 100644
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_asCellRange.xml
+++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_asCellRange.xml
@@ -68,17 +68,22 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>line = [\'tax_category/\' + x[0] for x in context.getTaxCategoryItemList()]\n
-column = [\'salary_range/\' + x[0] for x in context.getSalaryRangeItemList()]\n
-tab = []\n
+            <value> <string>cell_range = [\n
+  [\'tax_category/\' + x[0] for x in context.getTaxCategoryItemList()], # line\n
+  [\'salary_range/\' + x[0] for x in context.getSalaryRangeItemList()], # column \n
+  [] # tab\n
+]\n
 \n
-return [line, column, tab]\n
 \n
-#### J\xc3\xa9rome: original was : (why ?)\n
-if len(tab) :\n
-  cell_range = [line, column, tab]\n
-else :\n
-  cell_range = [line, column]\n
+cell_range = filter(lambda x: x != [], cell_range)\n
+\n
+if matrixbox :\n
+  ctool = context.getPortalObject().portal_categories\n
+  cell_range_item_list = []\n
+  for range in cell_range :\n
+    new_range = [  (x, ctool.resolveCategory(x).getTitleOrId()) for x in range]\n
+    cell_range_item_list.append(new_range)\n
+  return cell_range_item_list \n
 \n
 return cell_range\n
 </string> </value>
@@ -95,7 +100,7 @@ return cell_range\n
         </item>
         <item>
             <key> <string>_params</string> </key>
-            <value> <string>cellRangeAxe=None, matrixbox=0, **kw</string> </value>
+            <value> <string>matrixbox=0, **kw</string> </value>
         </item>
         <item>
             <key> <string>errors</string> </key>
@@ -115,13 +120,12 @@ return cell_range\n
                   <dictionary>
                     <item>
                         <key> <string>co_argcount</string> </key>
-                        <value> <int>2</int> </value>
+                        <value> <int>1</int> </value>
                     </item>
                     <item>
                         <key> <string>co_varnames</string> </key>
                         <value>
                           <tuple>
-                            <string>cellRangeAxe</string>
                             <string>matrixbox</string>
                             <string>kw</string>
                             <string>append</string>
@@ -131,11 +135,12 @@ return cell_range\n
                             <string>context</string>
                             <string>x</string>
                             <string>_getitem_</string>
-                            <string>line</string>
-                            <string>column</string>
-                            <string>tab</string>
-                            <string>len</string>
                             <string>cell_range</string>
+                            <string>filter</string>
+                            <string>ctool</string>
+                            <string>cell_range_item_list</string>
+                            <string>range</string>
+                            <string>new_range</string>
                           </tuple>
                         </value>
                     </item>
@@ -148,7 +153,6 @@ return cell_range\n
             <key> <string>func_defaults</string> </key>
             <value>
               <tuple>
-                <none/>
                 <int>0</int>
               </tuple>
             </value>
diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_getCellRangeItemList.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_getCellRangeItemList.xml
deleted file mode 100644
index 7900334362..0000000000
--- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetLine_getCellRangeItemList.xml
+++ /dev/null
@@ -1,178 +0,0 @@
-<?xml version="1.0"?>
-<ZopeData>
-  <record id="1" aka="AAAAAAAAAAE=">
-    <pickle>
-      <tuple>
-        <tuple>
-          <string>Products.PythonScripts.PythonScript</string>
-          <string>PythonScript</string>
-        </tuple>
-        <none/>
-      </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>[lines, cols, tabs] = context.PaySheetLine_asCellRange()\n
-\n
-line_items = []\n
-col_items  = []\n
-tab_items  = []\n
-\n
-for line_path in lines:\n
-  line_title = context.portal_categories.resolveCategory(line_path).getTitleOrId()\n
-  line_items.append((line_path, line_title))\n
-\n
-for col_path in cols:\n
-  col_title = context.portal_categories.resolveCategory(col_path).getTitleOrId()\n
-  col_items.append((col_path, col_title))\n
-\n
-for tab_path in tabs:\n
-  tab_title = context.portal_categories.resolveCategory(tab_path).getTitleOrId()\n
-  tab_items.append((tab_path, tab_title))\n
-\n
-return [line_items, col_items, tab_items]\n
-</string> </value>
-        </item>
-        <item>
-            <key> <string>_code</string> </key>
-            <value>
-              <none/>
-            </value>
-        </item>
-        <item>
-            <key> <string>_filepath</string> </key>
-            <value> <string>Script (Python):/nexedi/portal_skins/erp5_payroll/PaySheetLine_getCellRangeItemList</string> </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>_getattr_</string>
-                            <string>context</string>
-                            <string>_getiter_</string>
-                            <string>lines</string>
-                            <string>cols</string>
-                            <string>tabs</string>
-                            <string>line_items</string>
-                            <string>col_items</string>
-                            <string>tab_items</string>
-                            <string>line_path</string>
-                            <string>line_title</string>
-                            <string>col_path</string>
-                            <string>col_title</string>
-                            <string>tab_path</string>
-                            <string>tab_title</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>PaySheetLine_getCellRangeItemList</string> </value>
-        </item>
-        <item>
-            <key> <string>warnings</string> </key>
-            <value>
-              <tuple/>
-            </value>
-        </item>
-      </dictionary>
-    </pickle>
-  </record>
-</ZopeData>
-- 
2.30.9