[Erp5-report] r31089 yo - in /erp5/trunk/products/ERP5/bootstrap/erp5_core: SkinTemplateIte...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Dec 4 18:41:38 CET 2009


Author: yo
Date: Fri Dec  4 18:41:37 2009
New Revision: 31089

URL: http://svn.erp5.org?rev=31089&view=rev
Log:
2009-12-05 yo
* Stop raising a string in ERP5Type_asSecurityGroupId.
* Optimize ERP5Type_asSecurityGroupId a little.

Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml?rev=31089&r1=31088&r2=31089&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Type_asSecurityGroupId.xml [utf8] Fri Dec  4 18:41:37 2009
@@ -89,6 +89,7 @@
 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 @@
 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 @@
                             <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 @@
                             <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>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=31089&r1=31088&r2=31089&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] Fri Dec  4 18:41:37 2009
@@ -1,1 +1,1 @@
-1394
+1395




More information about the Erp5-report mailing list