Commit 4712b38e authored by Jean-Paul Smets's avatar Jean-Paul Smets

Removed useless and added some comments

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12976 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 38408f78
<?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
Part of the core of security mechanism - translates a list of categories\n
into a structure of codification codes.\n
\n
The differences to the "stock" implementation are:\n
\n
* sometimes we use Project\n
object instead of a category, and Project has reference instead of codification,\n
so we have to provide for it\n
\n
* category value can refer to a Person (by reference), then we look for the Person\n
instead of resolving category\n
\n
"""\n
\n
code_list = []\n
user_list = []\n
\n
# sort the category list lexicographically\n
# this prevents us to choose the exact order we want,\n
# but also prevents some human mistake to break everything by creating site_function instead of function_site\n
if category_order not in (None, \'\'):\n
category_order = list(category_order)\n
category_order.sort()\n
else:\n
category_order = []\n
\n
for base_category in category_order:\n
# BG - sometimes we fail if something is missing\n
category_list = kw.get(base_category)\n
if category_list is None:continue\n
if same_type(category_list, \'\'):\n
category_list = [category_list]\n
for category in category_list:\n
category_path = \'%s/%s\' % (base_category, category)\n
if base_category == \'reference\': # we will be looking for Person\n
res=context.portal_catalog(portal_type=\'Person\', reference=category)\n
if res is not None and len(res) == 1:\n
category_object = res[0].getObject()\n
else:\n
raise Exception("no person "+category)\n
else:\n
category_object = context.portal_categories.getCategoryValue(category_path)\n
if category_object in (None, \'\'):\n
raise "SecurityRoleDefinitionError", "Category \'%s\' doesn\'t exist" % (category_path)\n
if category_object.getPortalType() == \'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
# We define a group item here\n
# BG: if this is a Project, it has no codification but a reference instead\n
try:\n
category_code = category_object.getCodification() or category_object.getId()\n
except AttributeError:\n
category_code = category_object.getReference()\n
code_list.append(category_code)\n
\n
# Return a list of users or a single group\n
if user_list:\n
return user_list\n
code_list = [c for c in code_list if c is not None]\n
r = \'_\'.join(code_list)\n
return r\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>category_order, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>category_order</string>
<string>kw</string>
<string>code_list</string>
<string>user_list</string>
<string>None</string>
<string>list</string>
<string>_getattr_</string>
<string>_getiter_</string>
<string>base_category</string>
<string>category_list</string>
<string>same_type</string>
<string>category</string>
<string>category_path</string>
<string>context</string>
<string>res</string>
<string>len</string>
<string>_getitem_</string>
<string>category_object</string>
<string>Exception</string>
<string>user_name</string>
<string>category_code</string>
<string>AttributeError</string>
<string>append</string>
<string>$append0</string>
<string>c</string>
<string>r</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_asSecurityGroupId</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -70,6 +70,10 @@
<key> <string>_body</string> </key>
<value> <string>"""\n
Core security script - defines the way to get security groups of the current user.\n
\n
WARNING: providing such script in erp5_dms could be dangerous\n
if this conflicts with an existing production site which uses\n
deprecated ERP5Type_asSecurityGroupIdList\n
"""\n
\n
return (\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