Ticket #3435: serialize_file_stream.patch

File serialize_file_stream.patch, 1.3 KB (added by Chris Beaven, 18 years ago)
  • django/core/serializers/base.py

     
    107107        """
    108108        Return the fully serialized queryset.
    109109        """
    110         return self.stream.getvalue()
     110        # The file type doesn't have a getvalue method, so we'll do this
     111        # carefully.
     112        getvalue = getattr(self.stream, 'getvalue', None)
     113        if getvalue and callable(getvalue):
     114            return getvalue()
    111115
    112116class Deserializer(object):
    113117    """
  • django/core/serializers/json.py

     
    1919        simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder, **self.options)
    2020       
    2121    def getvalue(self):
    22         return self.stream.getvalue()
     22        # The file type doesn't have a getvalue method, so we'll do this
     23        # carefully.
     24        getvalue = getattr(self.stream, 'getvalue', None)
     25        if getvalue and callable(getvalue):
     26            return getvalue()
    2327
    2428def Deserializer(stream_or_string, **options):
    2529    """
Back to Top