aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/views.py
diff options
context:
space:
mode:
authorSimon Charette2012-12-30 17:52:56 -0500
committerSimon Charette2012-12-30 17:52:56 -0500
commitd4971605cc0f82315805c44ea8346f609b1f07bb (patch)
treee73e04f256b634868bfeaefe036bd96e1c0e749c /debug_toolbar/views.py
parent22ebebd29b5d42ae50e9681847784713fa67daf5 (diff)
downloaddjango-debug-toolbar-d4971605cc0f82315805c44ea8346f609b1f07bb.tar.bz2
Use the built-in json module on python >= 2.6.
`django.utils.simplejson` is pending deprecation as of django 1.5 and will be removed in 1.7.
Diffstat (limited to 'debug_toolbar/views.py')
-rw-r--r--debug_toolbar/views.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py
index a642541..18b9460 100644
--- a/debug_toolbar/views.py
+++ b/debug_toolbar/views.py
@@ -9,13 +9,17 @@ import django.views.static
from django.conf import settings
from django.http import HttpResponseBadRequest
from django.shortcuts import render_to_response
-from django.utils import simplejson
from debug_toolbar.utils.compat.db import connections
try:
+ import json
+except ImportError: # python < 2.6
+ from django.utils import simplejson as json
+
+try:
from hashlib import sha1
-except ImportError:
+except ImportError: # python < 2.5
from django.utils.hashcompat import sha_constructor as sha1
@@ -45,7 +49,7 @@ def sql_select(request):
if hash != request.GET.get('hash', ''):
return HttpResponseBadRequest('Tamper alert') # SQL Tampering alert
if sql.lower().strip().startswith('select'):
- params = simplejson.loads(params)
+ params = json.loads(params)
cursor = connections[alias].cursor()
cursor.execute(sql, params)
headers = [d[0] for d in cursor.description]
@@ -80,7 +84,7 @@ def sql_explain(request):
if hash != request.GET.get('hash', ''):
return HttpResponseBadRequest('Tamper alert') # SQL Tampering alert
if sql.lower().strip().startswith('select'):
- params = simplejson.loads(params)
+ params = json.loads(params)
cursor = connections[alias].cursor()
conn = connections[alias].connection
@@ -126,7 +130,7 @@ def sql_profile(request):
if hash != request.GET.get('hash', ''):
return HttpResponseBadRequest('Tamper alert') # SQL Tampering alert
if sql.lower().strip().startswith('select'):
- params = simplejson.loads(params)
+ params = json.loads(params)
cursor = connections[alias].cursor()
result = None
headers = None