Opened 8 years ago

Closed 8 years ago

#12369 closed (fixed)

cStringIO portability

Reported by: Jeff Bauer Owned by: niall
Component: Documentation Version: 1.1
Severity: Keywords: cStringIO portability
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


In reference to:

cStringIO is a great way to speed up complex reportlab pdfs. For portability in environments that don't have cStringIO, I would encourage django coders to use this idiom:

    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

Attachments (1)

outputting-pdf.diff (692 bytes) - added by niall 8 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by niall

Has patch: set
Owner: changed from nobody to niall
Status: newassigned

Added a simple patch that changes the code sample to use the try, except block and a simple explanation of why it's necessary after the code sample.

comment:3 Changed 8 years ago by Alex Gaynor

I'd simplify the explanation to just a parenthetical note that "cStringIO is not avilable in all enviroments, StringIO may be used in it's place in such circumstances".

Changed 8 years ago by niall

Attachment: outputting-pdf.diff added

comment:4 Changed 8 years ago by niall

Updated the patch, now just has a comment above the import with a one line description explaining what's happening.

comment:5 Changed 8 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:6 Changed 8 years ago by Gabriel Hurley

Resolution: fixed
Status: assignedclosed

(In [14076]) Fixed #12369 -- Improved example to account for environments where cStringIO is not available. Thanks to rubic for the report and niall for the patch.

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