Commit 7e611f84 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Acquire in categories in security scripts. Added security script to build a...

Acquire in categories in security scripts. Added security script to build a security group from self.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14860 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 90addf37
......@@ -70,7 +70,7 @@ def getSecurityCategoryFromAssignment(self, base_category_list, user_name, objec
if assignment.getValidationState() == 'open':
category_dict = {}
for base_category in base_category_list:
category_value_list = assignment.getValueList(base_category)
category_value_list = assignment.getAcquiredValueList(base_category)
if category_value_list:
for category_value in category_value_list:
if base_category in child_category_list:
......
......@@ -101,7 +101,7 @@ if object is None:\n
return []\n
\n
for base_category in base_category_list:\n
category_list.append({base_category: object.getCategoryMembershipList(base_category)})\n
category_list.append({base_category: object.getAcquiredCategoryMembershipList(base_category)})\n
\n
return category_list\n
</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
This script returns a list of dictionaries which represent\n
the security groups which a person is member of. It extracts\n
the categories from the current content and associates\n
it to a given base_category. It is useful in the\n
following cases:\n
\n
- calculate a security group based current object \n
in the context of a base category (ex. source_project).\n
This is used for example in ERP5 DMS to calculate\n
project security.\n
\n
The parameters are\n
\n
base_category_list -- list of category values we need to retrieve\n
user_name -- string obtained from getSecurityManager().getUser().getId()\n
object -- object which we want to assign roles to\n
portal_type -- portal type of object\n
\n
NOTE: for now, this script requires proxy manager\n
"""\n
\n
category_list = []\n
\n
if object is None:\n
return []\n
\n
for base_category in base_category_list:\n
category_list.append({base_category: object.getRelativeUrl()})\n
\n
return category_list\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>base_category_list, user_name, object, portal_type</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>base_category_list</string>
<string>user_name</string>
<string>object</string>
<string>portal_type</string>
<string>category_list</string>
<string>None</string>
<string>_getiter_</string>
<string>base_category</string>
<string>_getattr_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Type_getSecurityCategoryFromSelf</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -117,7 +117,7 @@ for assignment in person_object.contentValues(filter={\'portal_type\': \'Assignm
if assignment.getValidationState() == \'open\':\n
category_dict = {}\n
for base_category in base_category_list:\n
category_value_list = assignment.getValueList(base_category)\n
category_value_list = assignment.getAcquiredValueList(base_category)\n
if category_value_list:\n
for category_value in category_value_list:\n
category_dict.setdefault(base_category, []).append(\'%s*\' % category_value.getRelativeUrl())\n
......
......@@ -101,7 +101,7 @@ if object is None:\n
return []\n
\n
for base_category in base_category_list:\n
membership_list = map(lambda x: \'%s*\' % x, object.getCategoryMembershipList(base_category))\n
membership_list = map(lambda x: \'%s*\' % x, object.getAcquiredCategoryMembershipList(base_category))\n
category_list.append({base_category: membership_list})\n
\n
return category_list\n
......
......@@ -117,7 +117,7 @@ for assignment in person_object.contentValues(filter={\'portal_type\': \'Assignm
if assignment.getValidationState() == \'open\':\n
category_dict = {}\n
for base_category in base_category_list:\n
category_value_list = assignment.getValueList(base_category)\n
category_value_list = assignment.getAcquiredValueList(base_category)\n
if category_value_list:\n
for category_value in category_value_list:\n
if category_value.getPortalType() == \'Category\':\n
......
......@@ -103,7 +103,7 @@ if object is None:\n
# Consider all parents of all categories\n
for base_category in base_category_list:\n
member_list = []\n
for category in object.getValueList(base_category):\n
for category in object.getAcquiredValueList(base_category):\n
if category.getPortalType() == \'Category\':\n
while category.getPortalType() == \'Category\':\n
member_list.append(category.getRelativeUrl())\n
......
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