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
This commit is contained in:
Andrew Godwin 2011-01-08 15:07:45 +00:00
parent 1ad644c0f0
commit 614672d365
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):