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 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># category_order : list of base_categories we want to use to generate the group id\n
# kw : keys should be base categories,\n
# values should be value of corresponding relative urls (obtained by getBaseCategory())\n
#\n
# Example call : context.ERP5TypeSecurity_asGroupId(category_order=(\'site\', \'group\', \'function\'),\n
# site=\'france/lille\', group=\'nexedi\', function=\'accounting/accountant\')\n
# This will generate a string like \'LIL_NXD_ACT\' where "LIL", "NXD" and "ACT" are the codification\n
# of respecively "france/lille", "nexedi" and "accounting/accountant" categories\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
<value> <string>"""\n
This script is used to convert a list of categories into an security\n
identifier (security ID). It is invoked by two classes in ERP5:\n
\n
- ERP5Type.py to convert security definitions made of\n
multiple categories into security ID strings\n
\n
- ERP5GroupManager.py to convert an assignment definition\n
into a single security ID string. It should be noted here\n
that ERP5GroupManager.py also tries to invoke ERP5Type_asSecurityGroupIdList\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
code_list = []\n
user_list = []\n
......@@ -106,8 +130,15 @@ for base_category in category_order:\n
user_name = category_object.getReference()\n
if user_name is not None: user_list.append(user_name)\n
else:\n
# We define a group item here\n
category_code = category_object.getCodification() or category_object.getId()\n
# We define a group item here based on codification or reference is possible\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
\n
# Return a list of users or a single group\n
......@@ -173,6 +204,7 @@ return \'_\'.join(code_list)\n
<string>category_object</string>
<string>user_name</string>
<string>category_code</string>
<string>AttributeError</string>
</tuple>
</value>
</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