From 811105ca15ee3277dc6e8282d058060b188fe62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com> Date: Thu, 28 Aug 2008 14:59:55 +0000 Subject: [PATCH] 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 --- .../Counter%20Module/container_report.xml | 6 +- .../Baobab_matchUserFunction.xml | 191 ++++++++++++++++++ bt5/erp5_banking_core/bt/revision | 2 +- 3 files changed, 193 insertions(+), 6 deletions(-) create mode 100644 bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Baobab_matchUserFunction.xml diff --git a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Counter%20Module/container_report.xml b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Counter%20Module/container_report.xml index 1a3e48a4a3..686219e487 100644 --- a/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Counter%20Module/container_report.xml +++ b/bt5/erp5_banking_core/ActionTemplateItem/portal_types/Counter%20Module/container_report.xml @@ -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> diff --git a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Baobab_matchUserFunction.xml b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Baobab_matchUserFunction.xml new file mode 100644 index 0000000000..95b70fc2ca --- /dev/null +++ b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Baobab_matchUserFunction.xml @@ -0,0 +1,191 @@ +<?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> diff --git a/bt5/erp5_banking_core/bt/revision b/bt5/erp5_banking_core/bt/revision index 2415c06594..e966f9075d 100644 --- a/bt5/erp5_banking_core/bt/revision +++ b/bt5/erp5_banking_core/bt/revision @@ -1 +1 @@ -448 \ No newline at end of file +450 \ No newline at end of file -- 2.30.9