Opened 9 years ago

Closed 9 years ago

#26717 closed New feature (fixed)

Allow customizing stream attribute of Serializer for custom serializers

Reported by: Berker Peksag Owned by: Berker Peksag
Component: Core (Serialization) Version: dev
Severity: Normal Keywords:
Cc: Berker Peksag Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, Serializer.serialize() sets self.stream to io.StringIO if stream is not passed to django.core.serializers.serializer(): https://github.com/django/django/blob/31a9a965a36c5ce923692e5dac430ea6a1cbf2a0/django/core/serializers/base.py#L69

However, when implementing or using a custom serializer we either tell the users to pass stream=io.BytesIO() everytime they use it or need to make some unnecessary subclassing.

It would be nice to define a Serializer.stream attribute similar to Serializer.progress_class.

I noticed this while creating a msgpack serializer to understand what needs to be done in #15091.

I already have a patch to implement my proposal.

Change History (5)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Berker Peksag, 9 years ago

Owner: changed from nobody to Berker Peksag
Status: newassigned

comment:4 by Simon Charette, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 724dd204:

Fixed #26717 -- Added Serializer.stream_class to customize the stream.

Note: See TracTickets for help on using tickets.
Back to Top