[1.2.X] Fixed #14888 -- Removing duplicated code in serialisers. Thanks to eric.fortin.

Backport of [15163] from trunk

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Andrew Godwin 2011-01-08 15:14:24 +00:00
parent d065e7eed2
commit 989486d05d
3 changed files with 3 additions and 9 deletions

View File

@ -31,9 +31,9 @@ class Serializer(object):
""" """
self.options = options self.options = options
self.stream = options.get("stream", StringIO()) self.stream = options.pop("stream", StringIO())
self.selected_fields = options.get("fields") self.selected_fields = options.pop("fields", None)
self.use_natural_keys = options.get("use_natural_keys", False) self.use_natural_keys = options.pop("use_natural_keys", False)
self.start_serialization() self.start_serialization()
for obj in queryset: for obj in queryset:

View File

@ -18,9 +18,6 @@ class Serializer(PythonSerializer):
internal_use_only = False internal_use_only = False
def end_serialization(self): 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) simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
def getvalue(self): def getvalue(self):

View File

@ -38,9 +38,6 @@ class Serializer(PythonSerializer):
super(Serializer, self).handle_field(obj, field) super(Serializer, self).handle_field(obj, field)
def end_serialization(self): 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) yaml.dump(self.objects, self.stream, Dumper=DjangoSafeDumper, **self.options)
def getvalue(self): def getvalue(self):