# HG changeset patch # User Marcin Kuzminski # Date 1326651777 -7200 # Node ID fbddaf2f97281c078238f59584136f4bca6566d6 # Parent 69e95ad5b6f041765b0c0796e0c494fab234865c mail response garden diff -r 69e95ad5b6f0 -r fbddaf2f9728 rhodecode/lib/rcmail/response.py --- a/rhodecode/lib/rcmail/response.py Sun Jan 15 20:19:56 2012 +0200 +++ b/rhodecode/lib/rcmail/response.py Sun Jan 15 20:22:57 2012 +0200 @@ -41,17 +41,20 @@ from email.utils import parseaddr from email.mime.base import MIMEBase -ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc', 'Bcc'] +ADDRESS_HEADERS_WHITELIST = ['From', 'To', 'Delivered-To', 'Cc'] DEFAULT_ENCODING = "utf-8" VALUE_IS_EMAIL_ADDRESS = lambda v: '@' in v + def normalize_header(header): return string.capwords(header.lower(), '-') + class EncodingError(Exception): """Thrown when there is an encoding error.""" pass + class MailBase(object): """MailBase is used as the basis of lamson.mail and contains the basics of encoding an email. You actually can do all your email processing with this @@ -105,7 +108,6 @@ {'filename': filename}) self.parts.append(part) - def attach_text(self, data, ctype): """ This attaches a simpler text encoded part, which doesn't have a @@ -124,6 +126,7 @@ for x in p.walk(): yield x + class MailResponse(object): """ You are given MailResponse objects from the lamson.view methods, and @@ -194,6 +197,7 @@ 'content_type': content_type, 'data': data, 'disposition': disposition,}) + def attach_part(self, part): """ Attaches a raw MailBase part from a MailRequest (or anywhere) @@ -227,7 +231,6 @@ del self.base.parts[:] self.multipart = False - def update(self, message): """ Used to easily set a bunch of heading from another dict @@ -312,6 +315,7 @@ def keys(self): return self.base.keys() + def to_message(mail, separator="; "): """ Given a MailBase message, this will construct a MIMEPart @@ -334,7 +338,7 @@ try: out = MIMEPart(ctype, **params) - except TypeError, exc: # pragma: no cover + except TypeError, exc: # pragma: no cover raise EncodingError("Content-Type malformed, not allowed: %r; " "%r (Python ERROR: %s" % (ctype, params, exc.message)) @@ -382,7 +386,6 @@ self.set_payload(encoded, charset=charset) - def extract_payload(self, mail): if mail.body == None: return # only None, '' is still ok