Added error handling views and templates, added setting to log request errors to a file.

This commit is contained in:
Chris Church
2013-05-28 14:11:19 -04:00
parent e61a966464
commit 40dd9b08be
12 changed files with 117 additions and 12 deletions

View File

@@ -2,6 +2,8 @@
# All Rights Reserved.
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import get_object_or_404
from ansibleworks.main.models import *
@@ -26,6 +28,25 @@ import json as python_json
from base_views import *
from ansibleworks.main.access import *
def handle_error(request, status=404):
context = {}
print request.path, status
if request.path.startswith('/admin/'):
template_name = 'admin/%d.html' % status
else:
template_name = '%d.html' % status
return render_to_response(template_name, context,
context_instance=RequestContext(request))
def handle_403(request):
return handle_error(request, 403)
def handle_404(request):
return handle_error(request, 404)
def handle_500(request):
return handle_error(request, 500)
class ApiRootView(APIView):
'''
Ansible Commander REST API