Fixed #3435 -- Fixed serializing to a file stream. Patch from SmileyChris.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5075 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-04-25 10:12:05 +00:00
parent 74bab89178
commit e23ababb52
2 changed files with 11 additions and 8 deletions

View File

@ -105,9 +105,11 @@ class Serializer(object):
def getvalue(self):
"""
Return the fully serialized queryset.
Return the fully serialized queryset (or None if the output stream is
not seekable).
"""
return self.stream.getvalue()
if callable(getattr(self.stream, 'getvalue', None)):
return self.stream.getvalue()
class Deserializer(object):
"""

View File

@ -19,7 +19,8 @@ class Serializer(PythonSerializer):
simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder, **self.options)
def getvalue(self):
return self.stream.getvalue()
if callable(getattr(self.stream, 'getvalue', None)):
return self.stream.getvalue()
def Deserializer(stream_or_string, **options):
"""