Example #1
0
def grant_automatic_permissions_for_created_resource(resource):
    """
    Grant CRUDE permissions for a newly created resource to current principal.
    @type resource: str
    @param resource: resource path to grant permissions to
    @rtype: bool
    @return: True on success, False otherwise
    @raise RuntimeError: if the system principal has not been set
    """
    user = get_principal()
    if is_system_principal():
        raise RuntimeError(_('cannot grant auto permission on %s to %s') %
                           (resource, user))
    operations = [CREATE, READ, UPDATE, DELETE, EXECUTE]
    _permission_api.grant(resource, user, operations)
    return True
Example #2
0
File: cud.py Project: ehelms/pulp
 def grant_automatic_permissions_for_resource(self, resource):
     """
     Grant CRUDE permissions for a newly created resource to current principal.
     
     @type resource: str
     @param resource: resource path to grant permissions to
     
     @rtype: bool
     @return: True on success, False otherwise
     
     @raise PulpExecutionException: if the system principal has not been set
     """
     user = get_principal()
     if is_system_principal():
         raise PulpExecutionException(_('Cannot grant automatic permissions for [%s] on resource [%s]') %
                            (user, resource))
         
     operations = [self.CREATE, self.READ, self.UPDATE, self.DELETE, self.EXECUTE]
     self.grant(resource, user['login'], operations)
     return True