Opened 15 years ago

Closed 14 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: no UI/UX: no

Description

In reference to: http://docs.djangoproject.com/en/dev/howto/outputting-pdf/

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:

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

Attachments (1)

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

Download all attachments as: .zip

Change History (7)

comment:1 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by niall, 14 years ago

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 by Alex Gaynor, 14 years ago

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".

by niall, 14 years ago

Attachment: outputting-pdf.diff added

comment:4 by niall, 14 years ago

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

comment:5 by Tim Graham, 14 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Gabriel Hurley, 14 years ago

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