From ce5f08fda9116a8f3d235ca6be4954eb362db9a4 Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Tue, 19 May 2015 15:21:12 +0200 Subject: [PATCH] CMFActivity: make script with proxy roles usable as a grouping method --- product/CMFActivity/ActivityTool.py | 1 + product/CMFActivity/tests/testCMFActivity.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/product/CMFActivity/ActivityTool.py b/product/CMFActivity/ActivityTool.py index 52b18ad75e..7a03708b5c 100644 --- a/product/CMFActivity/ActivityTool.py +++ b/product/CMFActivity/ActivityTool.py @@ -453,6 +453,7 @@ class GroupedMessage(object): # XXX: Allowing restricted code to implement a grouping method is questionable # but there already exist some. + __parent__ = property(lambda self: self.object) # for object _guarded_writes = 1 # for result allow_class(GroupedMessage) diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py index f4dbff330b..41563ad9e3 100644 --- a/product/CMFActivity/tests/testCMFActivity.py +++ b/product/CMFActivity/tests/testCMFActivity.py @@ -3106,12 +3106,15 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): def test_restrictedGroupMethod(self): skin = self.portal.portal_skins.custom script_id = self.id() - createZODBPythonScript(skin, script_id, "message_list", """if 1: + script = createZODBPythonScript(skin, script_id, "message_list", """if 1: for m in message_list: m.result = m.object.getProperty(*m.args, **m.kw) """) + script.manage_proxy(("Manager",)) obj = self.portal.portal_activities.newActiveProcess(causality_value_list=( self.portal.person_module, self.portal.organisation_module)) + obj.manage_permission('Access contents information', ['Manager']) + self.logout() foo = obj.activate(activity='SQLQueue', group_method_id=script_id, active_process=obj.getPath()).foo -- 2.30.9