def request_user_has_resource_db_permission(permission_type):
    """
    A decorator meant to wrap post, put and delete Pecan REST controller methods.

    This decorator assumes the first argument passed to the decorated function is a resource
    reference or an ID.

    Internally, this decorator retrieves the object from the DB so it can perform the permission
    checking.

    Note: The same query happens inside the decorator function meaning this is not the most
    efficient approach and we should eventually cache the "get one" results.
    """
    valid_method_names = ['get_one', 'get', 'post', 'put', 'delete']

    def decorate(func):
        function_name = func.__name__
        if valid_method_names not in function_name:
            raise Exception('This decorator should only be used to wrap %s methods' %
                            (', '.join(valid_method_names)))

        @wraps(func)
        def func_wrapper(*args, **kwargs):
            controller_instance = args[0]
            resource_id = args[1]  # Note: This can either be id, name or ref

            get_one_db_method = controller_instance.get_one_db_method
            resource_db = get_one_db_method(resource_id)
            utils.assert_request_user_has_resource_db_permission(request=pecan.request,
                                                                 resource_db=resource_db,
                                                                 permission_type=permission_type)
            return func(*args, **kwargs)
        return func_wrapper
    return decorate
dataset/ETHPy150Open StackStorm/st2/st2common/st2common/rbac/decorators.py/request_user_has_resource_db_permission/swapped operands of `not in`