예제 #1
0
파일: utils.py 프로젝트: 7thStreet/lodgeit
def render_to_response(template_name, **context):
    """Render a template to a response. This automatically fetches
    the list of new replies for the layout template. It also
    adds the current request to the context. This is used for the
    welcome message.
    """
    from lodgeit.models import Paste

    request = local.request
    if request.method == "GET":
        context["new_replies"] = Paste.fetch_replies()
    return Response(render_template(template_name, **context), mimetype="text/html")
예제 #2
0
파일: utils.py 프로젝트: bluszcz/lodgeit
def render_to_response(template_name, **context):
    """Render a template to a response. This automatically fetches
    the list of new replies for the layout template. It also
    adds the current request to the context. This is used for the
    welcome message.
    """
    from lodgeit.models import Paste
    request = local.request
    if request.method == 'GET':
        context['new_replies'] = Paste.fetch_replies()
    return Response(render_template(template_name, **context),
                    mimetype='text/html')
예제 #3
0
    def show_paste(self, identifier, raw=False):
        """Show an existing paste."""
        linenos = local.request.args.get('linenos') != 'no'
        paste = Paste.get(identifier)
        if paste is None:
            raise NotFound()
        if raw:
            return Response(paste.code, mimetype='text/plain; charset=utf-8')

        style, css = get_style(local.request)
        return render_to_response('show_paste.html',
                                  paste=paste,
                                  style=style,
                                  css=css,
                                  styles=STYLES,
                                  linenos=linenos,
                                  new_replies=Paste.fetch_replies(),
                                  )
예제 #4
0
파일: pastes.py 프로젝트: sergiik/lodgeit
    def show_paste(self, identifier, raw=False):
        """Show an existing paste."""
        linenos = local.request.args.get('linenos') != 'no'
        paste = Paste.get(identifier)

        if (paste is None) or (paste.private and identifier.isdigit()):
            raise NotFound()
        if raw:
            return Response(paste.code, mimetype='text/plain; charset=utf-8')

        style, css = get_style(local.request)
        return render_to_response('show_paste.html',
                                  paste=paste,
                                  style=style,
                                  css=css,
                                  styles=STYLES,
                                  linenos=linenos,
                                  new_replies=Paste.fetch_replies(),
                                  )