示例#1
0
        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)
示例#2
0
文件: util.py 项目: Natim/circus-web
        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)
示例#3
0
文件: util.py 项目: Natim/circus-web
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)
示例#4
0
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)
示例#5
0
def set_message(message):
    session = get_session()
    session['message'] = message
    session.save()
示例#6
0
文件: util.py 项目: Natim/circus-web
def set_message(message):
    session = get_session()
    session['message'] = message
    session.save()