From e995de3bdb96d54b6400890dd1ed601cccbdf85b Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Thu, 4 Jun 2009 13:01:18 +0000
Subject: [PATCH] Fix relation strings field with "my_<base_category>" id.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27364 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_core/Base_getFieldParameterDict.xml  | 38 ++++++++-----------
 product/ERP5/bootstrap/erp5_core/bt/revision  |  2 +-
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getFieldParameterDict.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getFieldParameterDict.xml
index 44eb379aac..b126e37158 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getFieldParameterDict.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getFieldParameterDict.xml
@@ -57,27 +57,23 @@
   Get default relation string field parameters\n
   based on its id\n
 """\n
-field_id = context.getId()\n
-if not field_id.startswith(\'my_\'): return {} # this should not happen\n
+pieces = context.getId().split(\'_\')\n
+if pieces.pop(0) != \'my\':\n
+  return {} # this should not happen\n
 \n
-is_list = 0\n
-if field_id.endswith(\'_relative_url\'): idx = 2\n
-elif field_id.endswith(\'_title\'): idx = 1\n
-elif field_id.endswith(\'_title_list\'):\n
-  idx = 2\n
-  is_list = 1\n
-else: idx = 0\n
+if pieces[-1] == \'list\':\n
+  pieces.pop()\n
 \n
 # can it be translated title, or something else?\n
-\n
-pieces = field_id.split(\'_\')\n
-parameter_dict = dict()\n
-parameter_dict[\'base_category\'] = \'_\'.join(pieces[1:-idx])\n
-if is_list == 0:\n
-  parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:])\n
+if pieces[-2:] == (\'relative\', \'url\'):\n
+  idx = -2\n
+elif pieces[-1] == \'title\':\n
+  idx = -1\n
 else:\n
-  parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:-1])  \n
-return parameter_dict\n
+  idx = len(pieces)\n
+\n
+return {\'base_category\': \'_\'.join(pieces[:idx]),\n
+        \'catalog_index\': \'_\'.join(pieces[idx:])}\n
 </string> </value>
         </item>
         <item>
@@ -116,14 +112,10 @@ return parameter_dict\n
                           <tuple>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>field_id</string>
-                            <string>is_list</string>
-                            <string>idx</string>
                             <string>pieces</string>
-                            <string>dict</string>
-                            <string>parameter_dict</string>
                             <string>_getitem_</string>
-                            <string>_write_</string>
+                            <string>idx</string>
+                            <string>len</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index 71db39d571..08e9158390 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-1216
\ No newline at end of file
+1217
\ No newline at end of file
-- 
2.30.9