Code

Opened 4 years ago

Closed 4 years ago

#12369 closed (fixed)

cStringIO portability

Reported by: rubic 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:

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 4 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by niall

  • Has patch set
  • Owner changed from nobody to niall
  • Status changed from new to assigned

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 4 years ago by Alex

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 4 years ago by niall

comment:4 Changed 4 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 4 years ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 4 years ago by gabrielhurley

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.