From e73d2ed3460f0df69862d6b8b94b7d047c576fc8 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Thu, 22 Sep 2005 15:23:03 +0000
Subject: [PATCH] getFilteredRoleListFor uses RoleInformation.getRole() to get
 a dict   representation of the role. RoleInformation.getRole() uses the
 getBaseCategoryScript() accessor to get   the script id. This accessor has
 been modified to return the default   secutiry script if the user who
 configured the roles definitions did not   specify a script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3827 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/ERP5Type.py        | 9 ++-------
 product/ERP5Type/RoleInformation.py | 7 ++++++-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py
index e0728e16ce..4b842e313d 100755
--- a/product/ERP5Type/ERP5Type.py
+++ b/product/ERP5Type/ERP5Type.py
@@ -40,7 +40,6 @@ from RoleInformation import ori
 from zLOG import LOG
 
 ERP5TYPE_SECURITY_GROUP_ID_GENERATION_SCRIPT = 'ERP5Type_asSecurityGroupId'
-ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT = 'ERP5Type_getSecurityCategoryFromAssignment'
 
 class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
     """
@@ -224,12 +223,8 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase ):
 
                 # get the script and apply it if actual_base_category_list is not empty
                 if len(actual_base_category_list) > 0:
-                    if definition['base_category_script']:
-                        base_category_script_id = definition['base_category_script']
-                        base_category_script = getattr(object, base_category_script_id, None)
-                    else:
-                        base_category_script_id = ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT
-                        base_category_script = getattr(object, base_category_script_id, None)
+                    base_category_script_id = definition['base_category_script']
+                    base_category_script = getattr(object, base_category_script_id, None)
                     if base_category_script is not None:
                         # call the script, which should return either a dict or a list of dicts
                         category_result = base_category_script(actual_base_category_list, user_name, object, object.getPortalType())
diff --git a/product/ERP5Type/RoleInformation.py b/product/ERP5Type/RoleInformation.py
index 8e699ca5eb..6f64323486 100755
--- a/product/ERP5Type/RoleInformation.py
+++ b/product/ERP5Type/RoleInformation.py
@@ -28,6 +28,8 @@ from Permissions import ManagePortal
 
 from types import StringType
 
+ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT = 'ERP5Type_getSecurityCategoryFromAssignment'
+
 class RoleInformation( SimpleItem ):
 
     """ Represent a single selectable role.
@@ -132,7 +134,10 @@ class RoleInformation( SimpleItem ):
 
         """ Return the base_category_script id
         """
-        return getattr(self, 'base_category_script', '')
+        base_category_script = getattr(self, 'base_category_script', '')
+        if base_category_script:
+          return base_category_script
+        return ERP5TYPE_SECURITY_CATEGORY_GENERATION_SCRIPT
 
     security.declarePrivate( 'base_category' )
     def clone( self ):
-- 
2.30.9