Opened 9 years ago

Closed 5 years ago

#6667 closed New feature (wontfix)

Email compliant word wrapping

Reported by: Chris Beaven Owned by: Chris Beaven
Component: Core (Other) Version: master
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 9 years ago.
mail_wrapping.2.diff (6.9 KB) - added by Chris Beaven 9 years ago.
patch devoid of the text wrap optimisation

Download all attachments as: .zip

Change History (9)

comment:1 Changed 9 years ago by Chris Beaven

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 Changed 9 years ago by Chris Beaven

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 Changed 9 years ago by Malcolm Tredinnick

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.

Changed 9 years ago by Chris Beaven

Attachment: mail_wrapping.diff added

Changed 9 years ago by Chris Beaven

Attachment: mail_wrapping.2.diff added

patch devoid of the text wrap optimisation

comment:4 Changed 9 years ago by Chris Beaven

Ok, separated. See also: #6668

comment:5 Changed 6 years ago by Julien Phalip

Type: New feature

comment:6 Changed 6 years ago by Julien Phalip

Severity: Normal

comment:7 Changed 5 years ago by Alex Gaynor

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