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,8 +105,10 @@ 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).
"""
if callable(getattr(self.stream, 'getvalue', None)):
return self.stream.getvalue()
class Deserializer(object):

View File

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