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)
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)
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)
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)