code: def manage_permission_for(brain_or_object, permission, roles, acquire=0):
      
      obj = api.get_object(brain_or_object)
  
      if isinstance(roles, basestring):
          roles = [roles]
  
      for item in obj.ac_inherited_permissions(1):
          name, value = item[:2]
          if name == permission:
              permission = Permission(name, value, obj)
              if acquire:
                  roles = list(roles)
              else:
                  roles = tuple(roles)
              permission.setRoles(roles)
              return
  
      # Raise an error if the permission is invalid
      raise ValueError("The permission {} is invalid.".format(permission))
docs: Change the settings for the given permission.
  
      Code extracted from `IRoleManager.manage_permission`
  
      :param brain_or_object: Catalog brain or object
      :param permission: The permission to be granted
      :param roles: The roles the permission to be granted to
      :param acquire: Flag to acquire the permission