Commit 811105ca authored by Aurel's avatar Aurel

use of a generic script to match a user function with a given string

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23243 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1dd32b99
......@@ -93,11 +93,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string encoding="cdata"><![CDATA[
python: len([x for x in object.Baobab_getFunctionList([\'manager\']) if x in object.Baobab_getUserAssignedFunctionList()])>0
]]></string> </value>
<value> <string>python: object.Baobab_matchUserFunction([\'counter\'])</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</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>allow = False\n
\n
#context.log(\'group_list\',group_list)\n
\n
def match(criterion_list, reference_list):\n
for criterion in criterion_list:\n
if criterion in reference_list:\n
return True\n
return False\n
\n
if not allow and role_list is not None:\n
from AccessControl import getSecurityManager\n
roles = getSecurityManager().getUser().getRoles()\n
#context.log(\'roles\',roles)\n
allow = match(roles, role_list)\n
\n
if not allow and group_list is not None:\n
user_function_list = context.Baobab_getUserAssignedFunctionList()\n
function_list = context.Baobab_getFunctionList(group_list=group_list)\n
#context.log(\'user_function_list\',user_function_list)\n
#context.log(\'function_list\',function_list)\n
allow = match(user_function_list, function_list)\n
#context.log(\'allow\',allow)\n
return allow\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>group_list=None, role_list=None</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>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>group_list</string>
<string>role_list</string>
<string>False</string>
<string>allow</string>
<string>match</string>
<string>None</string>
<string>AccessControl</string>
<string>getSecurityManager</string>
<string>_getattr_</string>
<string>roles</string>
<string>context</string>
<string>user_function_list</string>
<string>function_list</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Baobab_matchUserFunction</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
448
\ No newline at end of file
450
\ No newline at end of file
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