diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml
index 828f3b2e6ac36aaa624f863158e01c86908935ad..24460893e67bfd56665bd8c3b32beaa6f06d3b5d 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml
@@ -89,6 +89,7 @@ to a Person instance. This is useful to implement user based local role assignme
 instead of abstract security based local roles.\n
 """\n
 portal = context.getPortalObject()\n
+getCategoryValue = portal.portal_categories.getCategoryValue\n
 \n
 # sort the category list lexicographically\n
 # this prevents us to choose the exact order we want,\n
@@ -105,38 +106,44 @@ list_of_list = []\n
 user_list = []\n
 for base_category in category_order:\n
   # It is acceptable for a category not to be defined\n
-  if kw.has_key(base_category):\n
+  try:\n
     category_list = kw[base_category]\n
-    associative_list = []\n
-    if same_type(category_list, \'\'):\n
-      category_list = [category_list]\n
-    for category in category_list:\n
-      if category.endswith(\'*\'):\n
-        category = category[:-1]\n
-        is_child_category = 1\n
-      else:\n
-        is_child_category = 0\n
-      category_path = \'%s/%s\' % (base_category, category)\n
-      category_object = portal.portal_categories.getCategoryValue(category_path)\n
-      if category_object in (None, \'\'):\n
-        raise "SecurityRoleDefinitionError", "Category \'%s\' doesn\'t exist" % (category_path)\n
-      portal_type = category_object.getPortalType()\n
-      if portal_type == \'Person\':\n
-        # We define a person here\n
-        user_name = category_object.getReference()\n
-        if user_name is not None: user_list.append(user_name)\n
-      else:\n
-        category_code = (category_object.getProperty(\'codification\') or\n
-                         category_object.getProperty(\'reference\') or\n
-                         category_object.getId())\n
-        if is_child_category: category_code += \'*\'\n
-        associative_list.append(category_code)\n
-    # Prevent making a cartesian product with an empty set\n
-    if associative_list:\n
-      list_of_list.append(associative_list)\n
+  except KeyError:\n
+    continue\n
+\n
+  associative_list = []\n
+  if isinstance(category_list, str):\n
+    category_list = [category_list]\n
+  for category in category_list:\n
+    if category[-1] == \'*\':\n
+      category = category[:-1]\n
+      is_child_category = 1\n
+    else:\n
+      is_child_category = 0\n
+    category_path = \'%s/%s\' % (base_category, category)\n
+    category_object = getCategoryValue(category_path)\n
+    if category_object is None:\n
+      raise RuntimeError("Security definition error (category %r not found)" % (category_path,))\n
+    portal_type = category_object.getPortalType()\n
+    if portal_type == \'Person\':\n
+      # We define a person here\n
+      user_name = category_object.getReference()\n
+      if user_name is not None:\n
+        user_list.append(user_name)\n
+    else:\n
+      category_code = (category_object.getProperty(\'codification\') or\n
+                        category_object.getProperty(\'reference\') or\n
+                        category_object.getId())\n
+      if is_child_category:\n
+        category_code += \'*\'\n
+      associative_list.append(category_code)\n
+  # Prevent making a cartesian product with an empty set\n
+  if associative_list:\n
+    list_of_list.append(associative_list)\n
 \n
 # Return a list of users if any was defined\n
-if user_list: return user_list\n
+if user_list:\n
+  return user_list\n
 \n
 # Compute the cartesian product and return the codes\n
 # return filter(lambda x: x, map(lambda x: \'_\'.join(x), cartesianProduct(list_of_list)))\n
@@ -182,6 +189,7 @@ return [\'_\'.join(x) for x in cartesianProduct(list_of_list) if x]\n
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>portal</string>
+                            <string>getCategoryValue</string>
                             <string>None</string>
                             <string>list</string>
                             <string>Products.ERP5Type.Utils</string>
@@ -192,12 +200,15 @@ return [\'_\'.join(x) for x in cartesianProduct(list_of_list) if x]\n
                             <string>base_category</string>
                             <string>_getitem_</string>
                             <string>category_list</string>
+                            <string>KeyError</string>
                             <string>associative_list</string>
-                            <string>same_type</string>
+                            <string>isinstance</string>
+                            <string>str</string>
                             <string>category</string>
                             <string>is_child_category</string>
                             <string>category_path</string>
                             <string>category_object</string>
+                            <string>RuntimeError</string>
                             <string>portal_type</string>
                             <string>user_name</string>
                             <string>category_code</string>
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index 83a8aedd3007f2a2fee0ee71acdec3ee11d777cc..669268d4de2cf4566b9e7f90af6a92ae68b774a0 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-1394
\ No newline at end of file
+1395
\ No newline at end of file