From c48d1f9e561de60e261974ad26f398331d47d415 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 27 Mar 2007 15:44:30 +0000
Subject: [PATCH] use fallback categories instead of hardcoding
 destination_region, source_region etc.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13724 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...ate_getMembershipCriterionCategoryList.xml | 26 +++++++++++++------
 product/ERP5/bootstrap/erp5_core/bt/revision  |  2 +-
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml
index 62ee639d7e..83f18f1f9e 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Predicate_getMembershipCriterionCategoryList.xml
@@ -78,13 +78,19 @@ for item in multimembership_base_list :\n
 \n
 category_list = []\n
 \n
+ctool = context.portal_categories\n
 for item in mixed_list:\n
-  if item in (\'destination_region\', \'source_region\'):\n
-    category = \'region\' # This must be made more generic\n
-    category_list += [(x[0], \'%s/%s\' % (item, x[1])) for x in \n
-                      context.portal_categories[category].getCategoryChildCompactLogicalPathItemList(base=1)]\n
-  else:\n
-    category_list += context.portal_categories[item].getCategoryChildCompactLogicalPathItemList(base=1)\n
+  base_category = ctool[item]\n
+  item_list = base_category.getCategoryChildCompactLogicalPathItemList(base=1)\n
+  if item_list == [[\'\', \'\']]:\n
+    for fallback_category in base_category.getFallbackBaseCategoryList():\n
+      fallback_category = ctool.restrictedTraverse(fallback_category, None)\n
+      if fallback_category:\n
+        item_list = [(\'%s/%s\' % (item, x[0]), \'%s/%s\' % (item, x[1])) for x in\n
+                     fallback_category.getCategoryChildCompactLogicalPathItemList(base=1)]\n
+        break\n
+\n
+  category_list.extend(item_list)\n
 \n
 return category_list\n
 </string> </value>
@@ -137,10 +143,14 @@ return category_list\n
                             <string>_getiter_</string>
                             <string>item</string>
                             <string>category_list</string>
-                            <string>category</string>
+                            <string>ctool</string>
+                            <string>_getitem_</string>
+                            <string>base_category</string>
+                            <string>item_list</string>
+                            <string>fallback_category</string>
+                            <string>None</string>
                             <string>append</string>
                             <string>$append0</string>
-                            <string>_getitem_</string>
                             <string>x</string>
                           </tuple>
                         </value>
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index 9e6181a6ed..4e66132b50 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-285
\ No newline at end of file
+282
\ No newline at end of file
-- 
2.30.9