summaryrefslogtreecommitdiffstats
path: root/packages/views
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-05-12 09:32:30 -0500
committerDan McGee <dan@archlinux.org>2012-05-12 09:32:30 -0500
commita5f5557493446bede78adb0584c88208234f874e (patch)
tree6225bf10e655410c49aaf464f8e22d2d5fc35267 /packages/views
parentf36d876aca5571f09032d0d2a67c8b1f1a3258c8 (diff)
downloadarchweb-a5f5557493446bede78adb0584c88208234f874e.tar.gz
archweb-a5f5557493446bede78adb0584c88208234f874e.zip
Use python json module directly in place of simplejson
As of Python 2.6, this is a builtin module that has all the same functions and capabilities of the Django simplejson module. Additionally simplejson is deprecated in the upcoming Django 1.5 release. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/views')
-rw-r--r--packages/views/__init__.py10
-rw-r--r--packages/views/search.py5
-rw-r--r--packages/views/signoff.py7
3 files changed, 9 insertions, 13 deletions
diff --git a/packages/views/__init__.py b/packages/views/__init__.py
index 60c3a46b..c1a035d0 100644
--- a/packages/views/__init__.py
+++ b/packages/views/__init__.py
@@ -1,4 +1,5 @@
import hashlib
+import json
from string import Template
from urllib import urlencode
@@ -8,7 +9,6 @@ from django.contrib.auth.models import User
from django.core.cache import cache
from django.http import HttpResponse, Http404
from django.shortcuts import get_object_or_404, redirect
-from django.utils import simplejson
from django.views.decorators.cache import cache_control
from django.views.decorators.http import require_GET, require_POST
from django.views.decorators.vary import vary_on_headers
@@ -55,7 +55,7 @@ def opensearch_suggest(request):
pkgname__startswith=search_term).values_list(
'pkgname', flat=True).order_by('pkgname').distinct()[:10]
results = [search_term, list(names)]
- to_json = simplejson.dumps(results, ensure_ascii=False)
+ to_json = json.dumps(results, ensure_ascii=False)
cache.set(cache_key, to_json, 300)
return HttpResponse(to_json, mimetype='application/x-suggestions+json')
@@ -197,8 +197,7 @@ def files(request, name, repo, arch):
def details_json(request, name, repo, arch):
pkg = get_object_or_404(Package,
pkgname=name, repo__name__iexact=repo, arch__name=arch)
- to_json = simplejson.dumps(pkg, ensure_ascii=False,
- cls=PackageJSONEncoder)
+ to_json = json.dumps(pkg, ensure_ascii=False, cls=PackageJSONEncoder)
return HttpResponse(to_json, mimetype='application/json')
def files_json(request, name, repo, arch):
@@ -212,8 +211,7 @@ def files_json(request, name, repo, arch):
'arch': pkg.arch.name.lower(),
'files': fileslist,
}
- to_json = simplejson.dumps(data, ensure_ascii=False,
- cls=PackageJSONEncoder)
+ to_json = json.dumps(data, ensure_ascii=False, cls=PackageJSONEncoder)
return HttpResponse(to_json, mimetype='application/json')
def download(request, name, repo, arch):
diff --git a/packages/views/search.py b/packages/views/search.py
index a09de0a7..a89822be 100644
--- a/packages/views/search.py
+++ b/packages/views/search.py
@@ -1,4 +1,5 @@
from datetime import datetime
+import json
from django import forms
from django.contrib.admin.widgets import AdminDateWidget
@@ -6,7 +7,6 @@ from django.contrib.auth.models import User
from django.db.models import Q
from django.http import HttpResponse
from django.views.generic import list_detail
-from django.utils import simplejson
from main.models import Package, Arch, Repo
from main.utils import make_choice
@@ -179,8 +179,7 @@ def search_json(request):
container['results'] = packages
container['valid'] = True
- to_json = simplejson.dumps(container, ensure_ascii=False,
- cls=PackageJSONEncoder)
+ to_json = json.dumps(container, ensure_ascii=False, cls=PackageJSONEncoder)
return HttpResponse(to_json, mimetype='application/json')
# vim: set ts=4 sw=4 et:
diff --git a/packages/views/signoff.py b/packages/views/signoff.py
index 63341a1d..61d949fc 100644
--- a/packages/views/signoff.py
+++ b/packages/views/signoff.py
@@ -1,3 +1,4 @@
+import json
from operator import attrgetter
from django import forms
@@ -7,7 +8,6 @@ from django.core.serializers.json import DjangoJSONEncoder
from django.db import transaction
from django.http import HttpResponse, Http404
from django.shortcuts import get_list_or_404, redirect, render
-from django.utils import simplejson
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
@@ -67,7 +67,7 @@ def signoff_package(request, name, repo, arch, revoke=False):
'known_bad': spec.known_bad,
'user': str(request.user),
}
- return HttpResponse(simplejson.dumps(data, ensure_ascii=False),
+ return HttpResponse(json.dumps(data, ensure_ascii=False),
mimetype='application/json')
return redirect('package-signoffs')
@@ -183,8 +183,7 @@ def signoffs_json(request):
'version': 2,
'signoff_groups': signoff_groups,
}
- to_json = simplejson.dumps(data, ensure_ascii=False,
- cls=SignoffJSONEncoder)
+ to_json = json.dumps(data, ensure_ascii=False, cls=SignoffJSONEncoder)
response = HttpResponse(to_json, mimetype='application/json')
return response