[MERGE] An EmailMessage class for bzrlib (v2)
Aaron Bentley
aaron.bentley at utoronto.ca
Mon Jul 9 19:47:38 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Adeodato Simó wrote:
> Added. I changed the send_email() function in the test to return a
> function instead, in order to test with different mime_subtypes. Please
> let me know if that is okay.
I found it surprising that send_mail took a subtype parameter. I can
see that it's convenient, though.
It's basically surprising that send_email does verification. Calling it
send_and_verify would help, I think.
> === modified file 'bzrlib/email_message.py'
> --- bzrlib/email_message.py 2007-07-09 13:07:15 +0000
> +++ bzrlib/email_message.py 2007-07-09 13:34:17 +0000
> @@ -91,7 +91,7 @@
>
> @staticmethod
> def send(config, from_address, to_address, subject, body, attachment=None,
> - attachment_filename=None):
> + attachment_filename=None, attachment_mime_subtype='plain'):
> """Create an email message and send it with SMTPConnection.
>
> :param config: config object to pass to SMTPConnection constructor.
> So it seems that non-MIME messages are a wanted feature. :-) I think
> that shoehorning this into EmailMessage itself is not a good option,
> because you cannot inherit from MIMEMultipart anymore, and have to use a
> hidden object, proxying attribute access, etc. (If there's a better way
> to achive that, by all means please tell me.)
A common approach would be to move as much code as possible into a
"mixin" superclass, and then use multiple inheritance,
e.g.
class EasyMixin(object):
pass
class EasyMIMEMail(MIMEMultipart, EasyMixin):
pass
class EasyMail(MIMENonMultipart, EasyMixin):
pass
> However, along the lines of what Martin proposes, I think it'd be
> feasible to have the staticmethod to act different whenever attachment
> is None, creatting a plain email.Message instead of a bzrlib.EmailMessage.
I think we'd want to retain the address encoding stuff when sending
non-multipart messages.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD4DBQFGkoLK0F+nu1YWqI0RAiuHAJ4lYx1jL7Fd0oh7hzrDYri1EXLe6ACYusAn
pZsHCOKtdSnQhpGVGZWcjg==
=uNyy
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list