Opened 16 years ago

Closed 13 years ago

#6667 closed New feature (wontfix)

Email compliant word wrapping

Reported by: Chris Beaven Owned by: Chris Beaven
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I had the case of wanting to correctly wrap text emails according to the relevant RFCs. I started by hacking django.utils.text wrap but then after some rethinking, decided to split it into a separate module (even if it is a bit of similar code).

On top of this, I refactored django.utils.text wrap method to boost it's efficiency.

Attachments (2)

mail_wrapping.diff (9.8 KB ) - added by Chris Beaven 16 years ago.
mail_wrapping.2.diff (6.9 KB ) - added by Chris Beaven 16 years ago.
patch devoid of the text wrap optimisation

Download all attachments as: .zip

Change History (9)

comment:1 by Chris Beaven, 16 years ago

Needs documentation: set
Owner: changed from nobody to Chris Beaven
Status: newassigned
Triage Stage: UnreviewedDesign decision needed

Has tests, but needs docs.

In a nutshell, EmailMessage has a new argument:

  • wrap_text -- which wraps the body text at 78 chars

At a lower level, SafeMIMEText now accepts two additional keyword arguments:

  • wrap_text -- which wraps the text at 78 chars
  • format_flowed -- still the format-flowed MIME parameter but assumes the text has already been wrapped

comment:2 by Chris Beaven, 16 years ago

Regarding the django.utils.text wrap refactor, here are the results of a timeit test:

Sentence
old: 1.43731307983
new: 0.553267002106

Paragraph
old: 4.15362501144
new: 1.33707404137

10 Paragraphs
old: 17.3589639664
new: 5.5629529953

comment:3 by Malcolm Tredinnick, 16 years ago

Please put the text wrapping refactoring in a separate ticket. They are independent and it's quite possible we'll take one (the speedup) and not the other.

by Chris Beaven, 16 years ago

Attachment: mail_wrapping.diff added

by Chris Beaven, 16 years ago

Attachment: mail_wrapping.2.diff added

patch devoid of the text wrap optimisation

comment:4 by Chris Beaven, 16 years ago

Ok, separated. See also: #6668

comment:5 by Julien Phalip, 13 years ago

Type: New feature

comment:6 by Julien Phalip, 13 years ago

Severity: Normal

comment:7 by Alex Gaynor, 13 years ago

Easy pickings: unset
Resolution: wontfix
Status: assignedclosed
UI/UX: unset

Discussion with Carl: wontfixing this, this is not demanded, easily lives outside of Django, and not particularly in scope for Django's primary use cases anyways. We'd probably still be interested in the speedups though, feel free to file a new ticket, or just commit yourself ;)

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