def wrapper(func): def client_or_redirect(*fargs, **fkwargs): if ensure_client: global client if client is None: session = get_session() if 'endpoint' in session: client = connect_to_endpoint(session['endpoint']) else: return redirect('/connect') return func(*fargs, **fkwargs) return route_(*args, **kwargs)(client_or_redirect)
def wrapper(func): def client_or_redirect(*fargs, **fkwargs): if ensure_client: client = get_client() session = get_session() if client is None: session = get_session() if session.get('endpoint', None) is not None: # XXX we need to pass SSH too here connect_to_circus(session['endpoint']) else: return redirect('/connect') return func(*fargs, **fkwargs) return route_(*args, **kwargs)(client_or_redirect)