def _inherited_permissions(object_uri, permission):
 (resource_name, plural) = _resource_endpoint(object_uri)
 try:
  object_perms_tree = PERMISSIONS_INHERITANCE_TREE[resource_name]
 except KeyError:
  return []
 attributes_permission = (('%s:attributes' % permission) if (not plural) else permission)
 inherited_perms = object_perms_tree.get(attributes_permission, object_perms_tree[permission])
 granters = set()
 for (related_resource_name, implicit_permissions) in inherited_perms.items():
  for permission in implicit_permissions:
   related_uri = _relative_object_uri(related_resource_name, object_uri)
   granters.add((related_uri, permission))
 return sorted(granters, key=(lambda uri_perm: len(uri_perm[0])), reverse=True)

def _inherited_permissions ( object_uri , permission ) : ( resource_name , plural ) = _resource_endpoint ( object_uri ) try : object_perms_tree = PERMISSIONS_INHERITANCE_TREE [ resource_name ] except KeyError : return [ ] attributes_permission = ( ( '%s:attributes' % permission ) if ( not plural ) else permission ) inherited_perms = object_perms_tree . get ( attributes_permission , object_perms_tree [ permission ] ) granters = set ( ) for ( related_resource_name , implicit_permissions ) in inherited_perms . items ( ) : for permission in implicit_permissions : related_uri = _relative_object_uri ( related_resource_name , object_uri ) granters . add ( ( related_uri , permission ) ) return sorted ( granters , key = ( lambda uri_perm : len ( uri_perm [ 0 ] ) ) , reverse = True )
build the list of all permissions that can grant access to the given object uri and permission .