Changeset 6922
- Timestamp:
- 12/17/07 00:53:15 (1 year ago)
- Files:
-
- django/trunk/django/core/management/commands/dumpdata.py (modified) (3 diffs)
- django/trunk/django/core/management/commands/loaddata.py (modified) (1 diff)
- django/trunk/django/core/serializers/base.py (modified) (1 diff)
- django/trunk/django/core/serializers/__init__.py (modified) (1 diff)
- django/trunk/django/core/serializers/json.py (modified) (1 diff)
- django/trunk/django/core/serializers/python.py (modified) (1 diff)
- django/trunk/django/core/serializers/pyyaml.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/commands/dumpdata.py
r6081 r6922 1 1 from django.core.management.base import BaseCommand, CommandError 2 from django.core import serializers 2 3 3 4 from optparse import make_option 4 5 5 6 class Command(BaseCommand): 7 serializer_formats = serializers.get_public_serializer_formats() 6 8 option_list = BaseCommand.option_list + ( 7 9 make_option('--format', default='json', dest='format', 8 help='Specifies the output serialization format for fixtures '),10 help='Specifies the output serialization format for fixtures. Formats available: %s' % serializer_formats), 9 11 make_option('--indent', default=None, dest='indent', type='int', 10 12 help='Specifies the indent level to use when pretty-printing output'), … … 15 17 def handle(self, *app_labels, **options): 16 18 from django.db.models import get_app, get_apps, get_models 17 from django.core import serializers18 19 19 20 format = options.get('format', 'json') … … 27 28 # Check that the serialization format exists; this is a shortcut to 28 29 # avoid collating all the objects and _then_ failing. 30 if format not in self.serializer_formats: 31 raise CommandError("Unknown serialization format: %s" % format) 32 29 33 try: 30 34 serializers.get_serializer(format) django/trunk/django/core/management/commands/loaddata.py
r6883 r6922 51 51 if len(parts) == 1: 52 52 fixture_name = fixture_label 53 formats = serializers.get_ serializer_formats()53 formats = serializers.get_public_serializer_formats() 54 54 else: 55 55 fixture_name, format = '.'.join(parts[:-1]), parts[-1] 56 if format in serializers.get_ serializer_formats():56 if format in serializers.get_public_serializer_formats(): 57 57 formats = [format] 58 58 else: django/trunk/django/core/serializers/base.py
r5658 r6922 23 23 """ 24 24 25 # Indicates if the implemented serializer is only available for 26 # internal Django use. 27 internal_use_only = False 28 25 29 def serialize(self, queryset, **options): 26 30 """ django/trunk/django/core/serializers/__init__.py
r6268 r6922 54 54 return _serializers.keys() 55 55 56 def get_public_serializer_formats(): 57 if not _serializers: 58 _load_serializers() 59 return [k for k, v in _serializers.iteritems() if not v.Serializer.internal_use_only] 60 56 61 def get_deserializer(format): 57 62 if not _serializers: django/trunk/django/core/serializers/json.py
r5409 r6922 21 21 Convert a queryset to JSON. 22 22 """ 23 internal_use_only = False 24 23 25 def end_serialization(self): 24 26 self.options.pop('stream', None) django/trunk/django/core/serializers/python.py
r6264 r6922 14 14 Serializes a QuerySet to basic Python objects. 15 15 """ 16 16 17 internal_use_only = True 18 17 19 def start_serialization(self): 18 20 self._current = None django/trunk/django/core/serializers/pyyaml.py
r6893 r6922 19 19 Convert a queryset to YAML. 20 20 """ 21 22 internal_use_only = False 21 23 22 24 def handle_field(self, obj, field):
