Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #6110 -- Mark the python format serializer as for internal use …

…only. Thanks, empty.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6922 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fc413b8f611677e51ea8c24e3b56a3716652a619 1 parent 6754be4
@malcolmt malcolmt authored
View
8 django/core/management/commands/dumpdata.py
@@ -1,11 +1,13 @@
from django.core.management.base import BaseCommand, CommandError
+from django.core import serializers
from optparse import make_option
class Command(BaseCommand):
+ serializer_formats = serializers.get_public_serializer_formats()
option_list = BaseCommand.option_list + (
make_option('--format', default='json', dest='format',
- help='Specifies the output serialization format for fixtures'),
+ help='Specifies the output serialization format for fixtures. Formats available: %s' % serializer_formats),
make_option('--indent', default=None, dest='indent', type='int',
help='Specifies the indent level to use when pretty-printing output'),
)
@@ -14,7 +16,6 @@ class Command(BaseCommand):
def handle(self, *app_labels, **options):
from django.db.models import get_app, get_apps, get_models
- from django.core import serializers
format = options.get('format', 'json')
indent = options.get('indent', None)
@@ -26,6 +27,9 @@ def handle(self, *app_labels, **options):
# Check that the serialization format exists; this is a shortcut to
# avoid collating all the objects and _then_ failing.
+ if format not in self.serializer_formats:
+ raise CommandError("Unknown serialization format: %s" % format)
+
try:
serializers.get_serializer(format)
except KeyError:
View
4 django/core/management/commands/loaddata.py
@@ -50,10 +50,10 @@ def handle(self, *fixture_labels, **options):
parts = fixture_label.split('.')
if len(parts) == 1:
fixture_name = fixture_label
- formats = serializers.get_serializer_formats()
+ formats = serializers.get_public_serializer_formats()
else:
fixture_name, format = '.'.join(parts[:-1]), parts[-1]
- if format in serializers.get_serializer_formats():
+ if format in serializers.get_public_serializer_formats():
formats = [format]
else:
formats = []
View
5 django/core/serializers/__init__.py
@@ -53,6 +53,11 @@ def get_serializer_formats():
_load_serializers()
return _serializers.keys()
+def get_public_serializer_formats():
+ if not _serializers:
+ _load_serializers()
+ return [k for k, v in _serializers.iteritems() if not v.Serializer.internal_use_only]
+
def get_deserializer(format):
if not _serializers:
_load_serializers()
View
4 django/core/serializers/base.py
@@ -22,6 +22,10 @@ class Serializer(object):
Abstract serializer base class.
"""
+ # Indicates if the implemented serializer is only available for
+ # internal Django use.
+ internal_use_only = False
+
def serialize(self, queryset, **options):
"""
Serialize a queryset.
View
2  django/core/serializers/json.py
@@ -20,6 +20,8 @@ class Serializer(PythonSerializer):
"""
Convert a queryset to JSON.
"""
+ internal_use_only = False
+
def end_serialization(self):
self.options.pop('stream', None)
self.options.pop('fields', None)
View
4 django/core/serializers/python.py
@@ -13,7 +13,9 @@ class Serializer(base.Serializer):
"""
Serializes a QuerySet to basic Python objects.
"""
-
+
+ internal_use_only = True
+
def start_serialization(self):
self._current = None
self.objects = []
View
2  django/core/serializers/pyyaml.py
@@ -19,6 +19,8 @@ class Serializer(PythonSerializer):
Convert a queryset to YAML.
"""
+ internal_use_only = False
+
def handle_field(self, obj, field):
# A nasty special case: base YAML doesn't support serialization of time
# types (as opposed to dates or datetimes, which it does support). Since
Please sign in to comment.
Something went wrong with that request. Please try again.