示例#1
0
    def target_func(env, target, *args, **key_args):
        """
        webtool internal target argument wrapper.
        """
        # Perform target lookup for callback function
        target = lookup_target(target)

        # Return 404 on target not found
        if target is None:
            return None # 404

        user = env['verified_user']

        # Reject user if not allowed to view this target
        if USE_AUTH:
            if user == None or target['name'] not in user.targets:
                return None # 404

        return func(env, target = target, *args, **key_args)
示例#2
0
    def target_func(target, *args, **key_args):
        """
        require_target internal target argument wrapper.
        """

        print "target_func"
        print key_args

        # Perform target lookup for callback function
        target = lookup_target(target)

        # Return 404 on target not found
        if target is None:
            return abort(404)

        # Reject user if not allowed to view this target
        if USE_AUTH:
            if g.user == None or target['name'] not in g.user.targets:
                return abort(404)  # 404

        print target, args, key_args
        return func(target=target, *args, **key_args)
示例#3
0
    def target_func(target, *args, **key_args):
        """
        require_target internal target argument wrapper.
        """

        print "target_func"
        print key_args

        # Perform target lookup for callback function
        target = lookup_target(target)

        # Return 404 on target not found
        if target is None:
            return abort(404)

        # Reject user if not allowed to view this target
        if USE_AUTH:
            if g.user == None or target['name'] not in g.user.targets:
                return abort(404) # 404

        print target, args, key_args
        return func(target = target, *args, **key_args)
示例#4
0
def handle_api_method(method, keys):
    if not ENABLE_API:
        return None
    if method not in known_methods:
        raise Exception('Unknown method')

    if 'target' in keys:
        target = keys['target']
        target = lookup_target(target)
        if target is None:
            print 'Returning null, target is invalid'
            return None


#    u = fetch_user(env)
#    # User can't be none, since we've already passed login.
#    if USE_AUTH and target not in user.targets:
#        print 'User is not allowed to use target: %s!' % target

    if method == 'torrentrequester':
        return known_methods[method](keys, target)
    else:
        return known_methods[method](keys, method, target)
示例#5
0
def handle_api_method(method, keys):
    if not ENABLE_API:
        return None
    if method not in known_methods:
        raise Exception('Unknown method')

    if 'target' in keys:
        target = keys['target']
        target = lookup_target(target)
        if target is None:
            print 'Returning null, target is invalid'
            return None

#    u = fetch_user(env)
#    # User can't be none, since we've already passed login.
#    if USE_AUTH and target not in user.targets:
#        print 'User is not allowed to use target: %s!' % target


    if method == 'torrentrequester':
        return known_methods[method](keys, target)
    else:
        return known_methods[method](keys, method, target)