|
9 | 9 | from django.conf import settings
|
10 | 10 | from django.http import HttpResponseBadRequest
|
11 | 11 | from django.shortcuts import render_to_response
|
12 |
| -from django.utils import simplejson |
13 | 12 |
|
14 | 13 | from debug_toolbar.utils.compat.db import connections
|
15 | 14 |
|
| 15 | +try: |
| 16 | + import json |
| 17 | +except ImportError: # python < 2.6 |
| 18 | + from django.utils import simplejson as json |
| 19 | + |
16 | 20 | try:
|
17 | 21 | from hashlib import sha1
|
18 |
| -except ImportError: |
| 22 | +except ImportError: # python < 2.5 |
19 | 23 | from django.utils.hashcompat import sha_constructor as sha1
|
20 | 24 |
|
21 | 25 |
|
@@ -45,7 +49,7 @@ def sql_select(request):
|
45 | 49 | if hash != request.GET.get('hash', ''):
|
46 | 50 | return HttpResponseBadRequest('Tamper alert') # SQL Tampering alert
|
47 | 51 | if sql.lower().strip().startswith('select'):
|
48 |
| - params = simplejson.loads(params) |
| 52 | + params = json.loads(params) |
49 | 53 | cursor = connections[alias].cursor()
|
50 | 54 | cursor.execute(sql, params)
|
51 | 55 | headers = [d[0] for d in cursor.description]
|
@@ -80,7 +84,7 @@ def sql_explain(request):
|
80 | 84 | if hash != request.GET.get('hash', ''):
|
81 | 85 | return HttpResponseBadRequest('Tamper alert') # SQL Tampering alert
|
82 | 86 | if sql.lower().strip().startswith('select'):
|
83 |
| - params = simplejson.loads(params) |
| 87 | + params = json.loads(params) |
84 | 88 | cursor = connections[alias].cursor()
|
85 | 89 |
|
86 | 90 | conn = connections[alias].connection
|
@@ -126,7 +130,7 @@ def sql_profile(request):
|
126 | 130 | if hash != request.GET.get('hash', ''):
|
127 | 131 | return HttpResponseBadRequest('Tamper alert') # SQL Tampering alert
|
128 | 132 | if sql.lower().strip().startswith('select'):
|
129 |
| - params = simplejson.loads(params) |
| 133 | + params = json.loads(params) |
130 | 134 | cursor = connections[alias].cursor()
|
131 | 135 | result = None
|
132 | 136 | headers = None
|
|
0 commit comments