diff --git a/product/ERP5/Document/BusinessTemplate.py b/product/ERP5/Document/BusinessTemplate.py index fbacbe4972deb0b94ef3ef8c931f7670a7a21987..0d011213dc1e17fbea33d494c61d741ccb9312c8 100644 --- a/product/ERP5/Document/BusinessTemplate.py +++ b/product/ERP5/Document/BusinessTemplate.py @@ -2463,7 +2463,7 @@ class ActionTemplateItem(ObjectTemplateItem): for path, action_dict in portal_type_dict.iteritems(): container = p.unrestrictedTraverse(path) container.manage_delObjects([obj.id - for obj in container.objectValues(portal_type='Action Information') + for obj in container.getActionList() if obj.reference in action_dict]) for obj in action_dict.itervalues(): container._importOldAction(obj) @@ -2544,7 +2544,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem): obj = p.unrestrictedTraverse("portal_types/%s" % relative_url.split('/', 1)[1]) self._objects[relative_url] = type_role_list = [] - for role in obj.objectValues(portal_type='Role Information'): + for role in obj.getRoleList(): type_role_dict = {} for k, v in aq_base(role).__getstate__().iteritems(): if k == 'condition': @@ -2647,8 +2647,7 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem): obj = p.unrestrictedTraverse(path, None) if obj is not None: # reset roles before applying - obj.manage_delObjects([x.id - for x in obj.objectValues(portal_type='Role Information')]) + obj.manage_delObjects([x.id for x in obj.getRoleList()]) type_roles_list = self._objects[roles_path] or [] for role_property_dict in type_roles_list: obj._importRole(role_property_dict) diff --git a/product/ERP5Security/tests/testERP5Security.py b/product/ERP5Security/tests/testERP5Security.py index c9fbd2bc8f21d3b2b2aff3097e1a408a6298753f..cce0d570248fb4b93c277d38a95b0de38a5851fa 100644 --- a/product/ERP5Security/tests/testERP5Security.py +++ b/product/ERP5Security/tests/testERP5Security.py @@ -378,8 +378,7 @@ class TestLocalRoleManagement(ERP5TypeTestCase): base_cat.manage_delObjects(list(base_cat.objectIds())) # clear role definitions for ti in self.getTypesTool().objectValues(): - ti.manage_delObjects([x.id - for x in ti.objectValues(portal_type='ERP5 Role Information')]) + ti.manage_delObjects([x.id for x in ti.getRoleList()]) # clear modules for module in self.portal.objectValues(): if module.getId().endswith('_module'): diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index 9d435fb04c230b147c50c24e522bbae7b19b8ea7..e00ade624db0c2bac7ca68a6eb280248cca828db 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -245,7 +245,7 @@ class ERP5TypeInformation(XMLObject, # which acquire their security definition from their parent # The downside of this optimisation is that it is not possible to # set a local role definition if the local role list is empty - if len(self.objectValues(portal_type='Role Information')): + if self.getRoleList(): self.updateLocalRolesOnObject(ob) # notify workflow after generating local roles, in order to prevent @@ -528,9 +528,7 @@ class ERP5TypeInformation(XMLObject, folder = aq_parent(folder) ec = createExprContext(folder, portal, ob) - for role in self.objectValues(portal_type='Role Information'): - if role.testCondition(ec): - yield role + return (role for role in self.getRoleList() if role.testCondition(ec)) security.declareProtected(Permissions.ManagePortal, 'updateRoleMapping') def updateRoleMapping(self, REQUEST=None, form_id=''): @@ -601,6 +599,16 @@ class ERP5TypeInformation(XMLObject, # USE_BASE_TYPE # + security.declarePrivate('getRoleList') + def getRoleList(self): + """Return all roles for this portal type""" + return self.objectValues(portal_type='Role Information') + + security.declarePrivate('getActionList') + def getActionList(self): + """Return all actions for this portal type""" + return self.objectValues(portal_type='Action Information') + def getIcon(self): return self.content_icon @@ -639,8 +647,7 @@ class ERP5TypeInformation(XMLObject, security.declarePrivate('listActions') def listActions(self, info=None, object=None): """ List all the actions defined by a provider.""" - return sorted(self.objectValues(portal_type='Action Information'), - key=lambda x: x.getFloatIndex()) + return sorted(self.getActionList(), key=lambda x: x.getFloatIndex()) def _importOldAction(self, old_action): from Products.ERP5Type.Document.ActionInformation import ActionInformation