Opened 7 years ago

Closed 4 years ago

#6667 closed New feature (wontfix)

Email compliant word wrapping

Reported by: SmileyChris Owned by: SmileyChris
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 SmileyChris 7 years ago.
mail_wrapping.2.diff (6.9 KB) - added by SmileyChris 7 years ago.
patch devoid of the text wrap optimisation

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation set
  • Needs tests unset
  • Owner changed from nobody to SmileyChris
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Design 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 7 years ago by SmileyChris

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 7 years ago by mtredinnick

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 7 years ago by SmileyChris

Changed 7 years ago by SmileyChris

patch devoid of the text wrap optimisation

comment:4 Changed 7 years ago by SmileyChris

Ok, separated. See also: #6668

comment:5 Changed 4 years ago by julien

  • Type set to New feature

comment:6 Changed 4 years ago by julien

  • Severity set to Normal

comment:7 Changed 4 years ago by Alex

  • Easy pickings unset
  • Resolution set to wontfix
  • Status changed from assigned to closed
  • 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