def server_error(request, template_name='500.html'):

    domain = get_domain_from_url(request.path) or ''


    # hat tip: http://www.arthurkoziel.com/2009/01/15/passing-mediaurl-djangos-500-error-view/
    t = loader.get_template(template_name)
    type, exc, tb = sys.exc_info()

    traceback_text = ''.join(traceback.format_tb(tb))
    traceback_key = uuid.uuid4().hex
    cache.cache.set(traceback_key, traceback_text, 60*60)

    return HttpResponseServerError(t.render(RequestContext(request,
        {'MEDIA_URL': settings.MEDIA_URL,
         'STATIC_URL': settings.STATIC_URL,
         'domain': domain,
         '500traceback': traceback_key,
        })))
500 error handler.
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/hqwebapp/views.py/server_error