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(url('connect')) return func(*fargs, **fkwargs)
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)
def render_template(template, **data): """Finds the given template and renders it with the given data. Also adds some data that can be useful to the template, even if not explicitely asked so. :param template: the template to render :param **data: the kwargs that will be passed when rendering the template """ tmpl = TMPLS.get_template(template) client = get_client() # send the last message stored in the session in addition, in the "message" # attribute. server = '%s://%s' % (request.urlparts.scheme, request.urlparts.netloc) return tmpl.render(client=client, version=__version__, session=get_session(), SERVER=server, **data)
def set_message(message): session = get_session() session['message'] = message session.save()