def respond(template, context={}, request=None, **kwargs): "Calls render_to_response with a RequestConext" from django.http import HttpResponse from django.template import RequestContext from django.template.loader import render_to_string if request: default = context_processors.default(request) default.update(context) else: default = context.copy() rendered = render_to_string(template, default, context_instance=request and RequestContext(request) or None) return HttpResponse(rendered, **kwargs)
def handler500(request): """ 500 error handler. Templates: `500.html` Context: None """ from django.template import Context, loader from django.http import HttpResponseServerError from overseer.context_processors import default import logging import sys try: context = default(request) except Exception, e: logging.error(e, exc_info=sys.exc_info(), extra={'request': request}) context = {}
def respond(template, context={}, request=None, **kwargs): "Calls render_to_response with a RequestConext" from django.http import HttpResponse from django.template import RequestContext from django.template.loader import render_to_string if request: default = context_processors.default(request) default.update(context) else: default = context.copy() rendered = render_to_string( template, default, context_instance=request and RequestContext(request) or None) return HttpResponse(rendered, **kwargs)