code: def get_permissions_for_role(role, brain_or_object):
      
      obj = api.get_object(brain_or_object)
  
      # Raise an error if the role is invalid
      valid_roles = get_valid_roles_for(obj)
      if role not in valid_roles:
          raise ValueError("The Role '{}' is invalid.".format(role))
  
      out = []
      for item in obj.ac_inherited_permissions(1):
          name, value = item[:2]
          # Permission maps a named permission to a set of attribute names
          permission = Permission(name, value, obj)
          if role in permission.getRoles():
              out.append(name)
      return out
docs: Return the permissions of the role which are granted on the object
  
      Code extracted from `IRoleManager.permissionsOfRole`
  
      :param role: The role to check the permission
      :param brain_or_object: Catalog brain or object
      :returns: List of permissions of the role