Skip to content

Commit db4561b

Browse files
committed
Switch from simplejson to json; it is available in Python 2.6
1 parent c9a3435 commit db4561b

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

feincms/admin/tree_editor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
# coding=utf-8
33
# ------------------------------------------------------------------------
44

5+
import json
6+
import logging
7+
58
from django.conf import settings as django_settings
69
from django.contrib import admin
710
from django.contrib.admin.views import main
811
from django.db.models import Q
912
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError
10-
from django.utils import simplejson
1113
from django.utils.safestring import mark_safe
1214
from django.utils.translation import ugettext_lazy as _, ugettext
1315

1416
from mptt.exceptions import InvalidMove
1517

1618
from feincms import settings
1719

18-
import logging
19-
2020

2121
# ------------------------------------------------------------------------
2222
def django_boolean_icon(field_val, alt_text=None, title=None):
@@ -316,7 +316,7 @@ def _toggle_boolean(self, request):
316316
d.append(b)
317317

318318
# TODO: Shorter: [ y for x,y in zip(a,b) if x!=y ]
319-
return HttpResponse(simplejson.dumps(d), mimetype="application/json")
319+
return HttpResponse(json.dumps(d), mimetype="application/json")
320320

321321
def get_changelist(self, request, **kwargs):
322322
return ChangeList
@@ -343,7 +343,7 @@ def changelist_view(self, request, extra_context=None, *args, **kwargs):
343343
self._refresh_changelist_caches()
344344

345345
extra_context = extra_context or {}
346-
extra_context['tree_structure'] = mark_safe(simplejson.dumps(
346+
extra_context['tree_structure'] = mark_safe(json.dumps(
347347
_build_tree_structure(self.model)))
348348

349349
return super(TreeEditor, self).changelist_view(request, extra_context, *args, **kwargs)

feincms/content/table/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import json
2+
13
from django.db import models
2-
from django.utils import simplejson
34
from django.utils.safestring import mark_safe
45
from django.utils.translation import ugettext_lazy as _
56

@@ -91,6 +92,6 @@ def render(self, **kwargs):
9192
def save(self, *args, **kwargs):
9293
# XXX ugly, but otherwise the decoder raises exceptions
9394
self.data = self.data.replace('\r', '\\r').replace('\n', '\\n').replace('\t', '\\t')
94-
self.html = self.data and self.FORMATTERS[self.type](simplejson.loads(self.data)) or u''
95+
self.html = self.data and self.FORMATTERS[self.type](json.loads(self.data)) or u''
9596

9697
super(TableContent, self).save(*args, **kwargs)

feincms/contrib/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import json
12
import logging
23

34
from django import forms
45
from django.db import models
56
from django.core.serializers.json import DjangoJSONEncoder
6-
from django.utils import simplejson as json
7+
78

89
class JSONFormField(forms.fields.CharField):
910
def clean(self, value, *args, **kwargs):

feincms/module/medialibrary/zip.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
from __future__ import absolute_import
1111

1212
from datetime import datetime
13+
import json
1314
import zipfile
1415
import os
1516
import time
1617

1718
from django.template.defaultfilters import slugify
18-
from django.utils import simplejson
1919
from django.conf import settings as django_settings
2020

2121
from .models import Category, MediaFile, MediaFileTranslation
@@ -43,7 +43,7 @@ def import_zipfile(category_id, overwrite, data):
4343
is_export_file = False
4444
info = {}
4545
try:
46-
info = simplejson.loads(z.comment)
46+
info = json.loads(z.comment)
4747
if info['export_magic'] == export_magic:
4848
is_export_file = True
4949
except:
@@ -75,7 +75,7 @@ def import_zipfile(category_id, overwrite, data):
7575

7676
info = {}
7777
if is_export_file:
78-
info = simplejson.loads(zi.comment)
78+
info = json.loads(zi.comment)
7979

8080
mf = None
8181
if overwrite:
@@ -139,11 +139,11 @@ def export_zipfile(site, queryset):
139139
info = { 'export_magic': export_magic,
140140
'categories': [ { 'id': cat.id, 'title': cat.title, 'slug': cat.slug, 'parent': cat.parent_id or 0, 'level': len(cat.path_list()) } for cat in used_categories ],
141141
}
142-
zip_file.comment = simplejson.dumps(info)
142+
zip_file.comment = json.dumps(info)
143143

144144
for mf in queryset:
145145
ctime = time.localtime(os.stat(mf.file.path).st_ctime)
146-
info = simplejson.dumps({
146+
info = json.dumps({
147147
'copyright': mf.copyright,
148148
'categories': [ cat.id for cat in mf.categories.all() ],
149149
'translations': [

tests/testapp/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
admin.autodiscover()
99

1010
urlpatterns = patterns('',
11-
url(r'^admin/', include(admin.site.urls) ),
11+
url(r'^admin/', include(admin.site.urls)),
1212

1313
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
1414
{'document_root': os.path.join(os.path.dirname(__file__), 'media/')}),

0 commit comments

Comments
 (0)