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")
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')
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(), )
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(), )