diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2008-10-07 13:32:27 +1100 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2008-10-07 13:32:27 +1100 |
commit | 65404776f7f0e975737a5c8c69dc0b2ae5fe93da (patch) | |
tree | 252e6d64092c0c44dc54103e05fa14ee2360a383 /apps/patchwork/models.py | |
parent | e0fac2b893fd69caedd00c9256ac1e59c8dcbc9b (diff) | |
download | patchwork-65404776f7f0e975737a5c8c69dc0b2ae5fe93da.tar.bz2 patchwork-65404776f7f0e975737a5c8c69dc0b2ae5fe93da.tar.xz |
[encoding] Don't output patch mbox as quoted-printable
git-am doesn't like quoted-printable, so output mbox files as raw 7- or
8-bit mbox files. This means we have to create a new MIMEText class, so
that the content isn't automatically QP-encoded on __init__().
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/models.py')
-rw-r--r-- | apps/patchwork/models.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py index 3cfbacd..02fb8b4 100644 --- a/apps/patchwork/models.py +++ b/apps/patchwork/models.py @@ -31,11 +31,13 @@ import string import random try: - from email.mime.text import MIMEText + from email.mime.nonmultipart import MIMENonMultipart + from email.encoders import encode_7or8bit import email.utils except ImportError: # Python 2.4 compatibility - from email.MIMEText import MIMEText + from email.MIMENonMultipart import MIMENonMultipart + from email.Encoders import encode_7or8bit import email.Utils email.utils = email.Utils @@ -167,6 +169,14 @@ class HashField(models.CharField): def db_type(self): return 'char(%d)' % self.n_bytes +class PatchMbox(MIMENonMultipart): + patch_charset = 'utf-8' + def __init__(self, _text): + MIMENonMultipart.__init__(self, 'text', 'plain', + **{'charset': self.patch_charset}) + self.set_payload(_text.encode(self.patch_charset)) + encode_7or8bit(self) + class Patch(models.Model): project = models.ForeignKey(Project) msgid = models.CharField(max_length=255, unique = True) @@ -238,7 +248,7 @@ class Patch(models.Model): body += self.content - mail = MIMEText(body, _charset = 'utf-8') + mail = PatchMbox(body) mail['Subject'] = self.name mail['Date'] = email.utils.formatdate( time.mktime(self.date.utctimetuple())) |