Commit 38408f78 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Better documlentation and better support for more mappings.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12974 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8e9dbd1e
...@@ -68,17 +68,41 @@ ...@@ -68,17 +68,41 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># category_order : list of base_categories we want to use to generate the group id\n <value> <string>"""\n
# kw : keys should be base categories,\n This script is used to convert a list of categories into an security\n
# values should be value of corresponding relative urls (obtained by getBaseCategory())\n identifier (security ID). It is invoked by two classes in ERP5:\n
#\n \n
# Example call : context.ERP5TypeSecurity_asGroupId(category_order=(\'site\', \'group\', \'function\'),\n - ERP5Type.py to convert security definitions made of\n
# site=\'france/lille\', group=\'nexedi\', function=\'accounting/accountant\')\n multiple categories into security ID strings\n
# This will generate a string like \'LIL_NXD_ACT\' where "LIL", "NXD" and "ACT" are the codification\n \n
# of respecively "france/lille", "nexedi" and "accounting/accountant" categories\n - ERP5GroupManager.py to convert an assignment definition\n
#\n into a single security ID string. It should be noted here\n
# ERP5Type_asSecurityGroupId can also return a list of users whenever a category points\n that ERP5GroupManager.py also tries to invoke ERP5Type_asSecurityGroupIdList\n
# to a Person instance. This is useful to implement user based local role assignments\n (DEPRECATED) in order associate a user to multiple security groups.\n
In this case ERP5Type_asSecurityGroupId is not invoked.\n
\n
The script takes the following parameters:\n
\n
category_order - list of base_categories we want to use to generate the group id\n
kw - keys should be base categories, values should be value\n
of corresponding relative urls (obtained by getBaseCategory())\n
\n
Example call:\n
context.ERP5TypeSecurity_asGroupId(category_order=(\'site\', \'group\', \'function\'),\n
site=\'france/lille\', group=\'nexedi\', function=\'accounting/accountant\')\n
\n
This will generate a string like \'LIL_NXD_ACT\' where "LIL", "NXD" and "ACT" are\n
the codification of respecively "france/lille", "nexedi" and "accounting/accountant" categories\n
\n
If the category points to a document portal type (ex. trade condition, project, etc.),\n
and if no codification property is defined for this type of object,\n
the security ID group is generated by considering the object reference or\n
the object ID.\n
\n
ERP5Type_asSecurityGroupId can also return a list of users whenever a category points\n
to a Person instance. This is useful to implement user based local role assignments\n
instead of abstract security based local roles.\n
"""\n
\n \n
code_list = []\n code_list = []\n
user_list = []\n user_list = []\n
...@@ -106,8 +130,15 @@ for base_category in category_order:\n ...@@ -106,8 +130,15 @@ for base_category in category_order:\n
user_name = category_object.getReference()\n user_name = category_object.getReference()\n
if user_name is not None: user_list.append(user_name)\n if user_name is not None: user_list.append(user_name)\n
else:\n else:\n
# We define a group item here\n # We define a group item here based on codification or reference is possible\n
category_code = category_object.getCodification() or category_object.getId()\n # ID, else\n
try:\n
category_code = category_object.getCodification() or category_object.getId()\n
except AttributeError:\n
try:\n
category_code = category_object.getReference() or category_object.getId()\n
except AttributeError:\n
category_code = category_object.getId()\n
code_list.append(category_code)\n code_list.append(category_code)\n
\n \n
# Return a list of users or a single group\n # Return a list of users or a single group\n
...@@ -173,6 +204,7 @@ return \'_\'.join(code_list)\n ...@@ -173,6 +204,7 @@ return \'_\'.join(code_list)\n
<string>category_object</string> <string>category_object</string>
<string>user_name</string> <string>user_name</string>
<string>category_code</string> <string>category_code</string>
<string>AttributeError</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment