summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2011-01-08 15:07:45 +0000
committerAndrew Godwin <andrew@aeracode.org>2011-01-08 15:07:45 +0000
commit614672d365d6761353dbd11a8967a254d97035b7 (patch)
tree846fa79a4c3941df9f21bb15d15787871e9ca156
parent1ad644c0f052a60903ed0b94defe0c04fca47d06 (diff)
Fixed #14888 -- Removing duplicated code in serialisers. Thanks to eric.fortin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15163 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/serializers/base.py6
-rw-r--r--django/core/serializers/json.py3
-rw-r--r--django/core/serializers/pyyaml.py3
3 files changed, 3 insertions, 9 deletions
diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py
index 190636e670..cdcc7fa36a 100644
--- a/django/core/serializers/base.py
+++ b/django/core/serializers/base.py
@@ -31,9 +31,9 @@ class Serializer(object):
"""
self.options = options
- self.stream = options.get("stream", StringIO())
- self.selected_fields = options.get("fields")
- self.use_natural_keys = options.get("use_natural_keys", False)
+ self.stream = options.pop("stream", StringIO())
+ self.selected_fields = options.pop("fields", None)
+ self.use_natural_keys = options.pop("use_natural_keys", False)
self.start_serialization()
for obj in queryset:
diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py
index b82c0a0ec7..b8119f54d4 100644
--- a/django/core/serializers/json.py
+++ b/django/core/serializers/json.py
@@ -18,9 +18,6 @@ class Serializer(PythonSerializer):
internal_use_only = False
def end_serialization(self):
- self.options.pop('stream', None)
- self.options.pop('fields', None)
- self.options.pop('use_natural_keys', None)
simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
def getvalue(self):
diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py
index 2ca68fe442..c443b63bc9 100644
--- a/django/core/serializers/pyyaml.py
+++ b/django/core/serializers/pyyaml.py
@@ -38,9 +38,6 @@ class Serializer(PythonSerializer):
super(Serializer, self).handle_field(obj, field)
def end_serialization(self):
- self.options.pop('stream', None)
- self.options.pop('fields', None)
- self.options.pop('use_natural_keys', None)
yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options)
def getvalue(self):