From fe53652b2c5430a234e091da97dd16293f7bd96e Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Fri, 12 May 2006 17:19:49 +0000 Subject: [PATCH] Added support for explicit local roles. Added support to retrieve instance property map. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7253 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/ERP5Type.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 1315ba3976..ecfea85734 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -242,6 +242,24 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation def getGroupList( self ): return self.defined_group_list + security.declareProtected( ERP5Permissions.AccessContentsInformation, 'getInstancePropertyMap' ) + def getInstancePropertyMap(self): + """ + Returns the list of properties which are specific to the portal type. + + We do this by creating a temp object at the root of the portal + and invoking propertyMap + """ + from Products.ERP5Type import Document + # Access the factory method + factory_method = getattr(Document, "newTemp%s" % self.id) # Fix + id = "some_very_unlikely_temp_object_id_which_should_not_exist" + portal = self.portal_url.getPortalObject() + portal_ids = portal.objectIds() + while id in portal_ids: + id = id + "d" + return factory_method(portal, id).propertyMap() + security.declareProtected(ERP5Permissions.ModifyPortalContent, 'assignRoleToSecurityGroup') def assignRoleToSecurityGroup(self, object, user_name = None): @@ -265,7 +283,20 @@ class ERP5TypeInformation( FactoryTypeInformation, RoleProviderBase, Translation # Retrieve applicable roles role_mapping = self.getFilteredRoleListFor(object=object) # kw provided in order to take any appropriate action #LOG('ERP5TypeInformation', 0, 'role_mapping = %r, object = %r' % (role_mapping, object)) + + # Create an empty local Role Definition dict role_category_list_dict = {} + + # Fill it with explicit local roles defined as subobjects of current object + if getattr(aq_base(object), 'isPrincipiaFolderish', 0): + for roledef in object.objectValues(spec = 'ERP5 Role Definition'): + role_category_list_dict.setdefault(roledef.getRoleName(), []).append( + { + 'category_order' : ['agent'], + 'agent' : roledef.getAgentList() + }) + + # Then parse role mapping for role_text, definition_list in role_mapping.items(): # For each role definition, we look for the base_category_script # and try to use it to retrieve the values for the base_category list -- 2.30.9