From ca9cb0c0998d3ddd8ff631a789d757ed47ef0446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 17 Sep 2010 11:45:57 +0000 Subject: [PATCH] 38412 was not working when security implementation was set set to python, the isinstance check was returning false git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38449 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Accessor/Base.py | 38 ++++++++++--------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/product/ERP5Type/Accessor/Base.py b/product/ERP5Type/Accessor/Base.py index 660a4c9239..8e66d351c3 100644 --- a/product/ERP5Type/Accessor/Base.py +++ b/product/ERP5Type/Accessor/Base.py @@ -109,23 +109,16 @@ class Setter(Method): def rolesForPermissionOn(ob): im_self = ob.im_self name = '%s__roles__' % ob.__name__ - # we explictly call _aq_dynamic to prevent acquiering the attribute + # Lookup on the class, as getRoles gives priority to ob.__roles__ + # over class.ob__roles__, this way we have an opportunity to define + # security on the class for generated methods. + # We explictly call _aq_dynamic to prevent acquiering the attribute # from container - roles = im_self._aq_dynamic(name) + roles = getattr(im_self.__class__, name, im_self._aq_dynamic(name)) if roles is None: - # lookup on the class, as getRoles gives priority to ob.__roles__ - # over class.ob__roles__, this way we have an opportunity to define - # security on the class for generated methods. - class_role = getattr(im_self.__class__, name, im_self) - if class_role is not im_self: - if isinstance(class_role, PermissionRole): - return class_role.__of__(im_self) - return class_role - return rolesForPermissionOn(None, im_self, ('Manager',), - '_Modify_portal_content_Permission') - else: - # wrap explicitly, because we used _aq_dynamic - return roles.__of__(im_self) + return rolesForPermissionOn(None, im_self, ('Manager',), + '_Modify_portal_content_Permission') + return roles.__of__(im_self) from Products.CMFCore.Expression import Expression @@ -198,18 +191,11 @@ class Getter(Method): name = '%s__roles__' % ob.__name__ # we explictly call _aq_dynamic to prevent acquiering the attribute # from container - roles = im_self._aq_dynamic(name) + roles = getattr(im_self.__class__, name, im_self._aq_dynamic(name)) if roles is None: - class_role = getattr(im_self.__class__, name, im_self) - if class_role is not im_self: - if isinstance(class_role, PermissionRole): - return class_role.__of__(im_self) - return class_role - return rolesForPermissionOn(None, im_self, ('Manager',), - '_Access_contents_information_Permission') - else: - # wrap explicitly, because we used _aq_dynamic - return roles.__of__(im_self) + return rolesForPermissionOn(None, im_self, ('Manager',), + '_Access_contents_information_Permission') + return roles.__of__(im_self) class Tester(Method): -- 2.30.9