diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-04-29 19:58:00 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-04-29 19:58:00 +0200 |
| commit | cec6bd5a59547dc97fe98975c570fc27a1e970be (patch) | |
| tree | d084ff2008e4bba125c4b28297d6469992f2ec95 /docs | |
| parent | ee0a7c741e98214bac7eeb60b848cf099ff28836 (diff) | |
Fixed #18023 -- Removed bundled simplejson.
And started the deprecation path for django.utils.simplejson.
Thanks Alex Ogier, Clueless, and other contributors for their
work on the patch.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/_ext/djangodocs.py | 14 | ||||
| -rw-r--r-- | docs/internals/deprecation.txt | 3 | ||||
| -rw-r--r-- | docs/releases/1.5.txt | 13 | ||||
| -rw-r--r-- | docs/topics/class-based-views.txt | 2 | ||||
| -rw-r--r-- | docs/topics/serialization.txt | 23 |
5 files changed, 23 insertions, 32 deletions
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py index 3cf00a38e1..d4b0b43ca7 100644 --- a/docs/_ext/djangodocs.py +++ b/docs/_ext/djangodocs.py @@ -1,20 +1,11 @@ """ Sphinx plugins for Django documentation. """ +import json import os import re from docutils import nodes, transforms -try: - import json -except ImportError: - try: - import simplejson as json - except ImportError: - try: - from django.utils import simplejson as json - except ImportError: - json = None from sphinx import addnodes, roles, __version__ as sphinx_ver from sphinx.builders.html import StandaloneHTMLBuilder @@ -210,9 +201,6 @@ class DjangoStandaloneHTMLBuilder(StandaloneHTMLBuilder): def finish(self): super(DjangoStandaloneHTMLBuilder, self).finish() - if json is None: - self.warn("cannot create templatebuiltins.js due to missing simplejson dependency") - return self.info(bold("writing templatebuiltins.js...")) xrefs = self.env.domaindata["std"]["objects"] templatebuiltins = { diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index e3a5e1a40b..2f594536c5 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -268,6 +268,9 @@ these changes. See the :doc:`Django 1.5 release notes</releases/1.5>` for more details on these changes. +* The module ``django.utils.simplejson`` will be removed. The standard library +provides :mod:`json` which should be used instead. + * The function ``django.utils.itercompat.product`` will be removed. The Python builtin version should be used instead. diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt index dcf050f2ae..4f6b05f8f4 100644 --- a/docs/releases/1.5.txt +++ b/docs/releases/1.5.txt @@ -58,8 +58,17 @@ Backwards incompatible changes in 1.5 Features deprecated in 1.5 ========================== -itercompat.product -~~~~~~~~~~~~~~~~~~ +``django.utils.simplejson`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Since Django 1.5 drops support for Python 2.5, all supported versions of +Python provide the :mod:`json` module in their standard library. This module +is actually a version of ``simplejson`` distributed by Python, so Django no +longer needs to provide a copy. Any use of :mod:`django.utils.simplejson` can +be safely changed to :mod:`json`. + +``itercompat.product`` +~~~~~~~~~~~~~~~~~~~~~~ The :func:`~django.utils.itercompat.product` function has been deprecated. Use the builtin `itertools.product` instead. diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt index 6df8f78250..abac22000f 100644 --- a/docs/topics/class-based-views.txt +++ b/docs/topics/class-based-views.txt @@ -501,8 +501,8 @@ different rendering behavior. For example, a simple JSON mixin might look something like this:: + import json from django import http - from django.utils import simplejson as json class JSONResponseMixin(object): def render_to_response(self, context): diff --git a/docs/topics/serialization.txt b/docs/topics/serialization.txt index d7d72ec48a..d5a5282945 100644 --- a/docs/topics/serialization.txt +++ b/docs/topics/serialization.txt @@ -143,15 +143,13 @@ Identifier Information ========== ============================================================== ``xml`` Serializes to and from a simple XML dialect. -``json`` Serializes to and from JSON_ (using a version of simplejson_ - bundled with Django). +``json`` Serializes to and from JSON_. ``yaml`` Serializes to YAML (YAML Ain't a Markup Language). This serializer is only available if PyYAML_ is installed. ========== ============================================================== .. _json: http://json.org/ -.. _simplejson: http://undefined.org/python/#simplejson .. _PyYAML: http://www.pyyaml.org/ Notes for specific serialization formats @@ -169,28 +167,21 @@ For example:: json_serializer = serializers.get_serializer("json")() json_serializer.serialize(queryset, ensure_ascii=False, stream=response) -The Django source code includes the simplejson_ module. However, if you're -using Python 2.6 or later (which includes a builtin version of the module), Django will -use the builtin ``json`` module automatically. If you have a system installed -version that includes the C-based speedup extension, or your system version is -more recent than the version shipped with Django (currently, 2.0.7), the -system version will be used instead of the version included with Django. - -Be aware that if you're serializing using that module directly, not all Django -output can be passed unmodified to simplejson. In particular, :ref:`lazy -translation objects <lazy-translations>` need a `special encoder`_ written for -them. Something like this will work:: +Be aware that not all Django output can be passed unmodified to :mod:`json`. +In particular, :ref:`lazy translation objects <lazy-translations>` need a +`special encoder`_ written for them. Something like this will work:: + import json from django.utils.functional import Promise from django.utils.encoding import force_unicode - class LazyEncoder(simplejson.JSONEncoder): + class LazyEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, Promise): return force_unicode(obj) return super(LazyEncoder, self).default(obj) -.. _special encoder: http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.7/docs/index.html +.. _special encoder: http://docs.python.org/library/json.html#encoders-and-decoders .. _topics-serialization-natural-keys: |
