classification
Title: Master patch for content manager addition to email package
Type: enhancement Stage: resolved
Components: email Versions: Python 3.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, eric.snow, python-dev, r.david.murray, serhiy.storchaka, sjt
Priority: normal Keywords: patch

Created on 2013-08-31 03:10 by r.david.murray, last changed 2014-02-01 22:50 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
master_content_manager.patch r.david.murray, 2013-08-31 03:09 review
master_content_manager.patch r.david.murray, 2013-10-09 21:12 review
master_content_manager.patch r.david.murray, 2013-10-12 02:45 review
master_content_manager.patch r.david.murray, 2013-10-12 21:41 review
Messages (11)
msg196613 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-08-31 03:09
Since the only way to get a rietveld review link for all the changes is to post a single complete patch, I'm doing so in this issue.  Feel free to review based on either this or the separate patches posted in issue 18785, issue 18860, and issue 18890.

There are a couple of bug fixes in this code, but for the most part it is the addition of a new sub-modulej, and a new subclass to the message.py code, plus the accompanying documentation.

Note that this pretty much completes the proposed API additions to the email module.  There may be some additional small tweaks, and there will certainly be some additional support code for specific message header and message types later, but checking this in will mark the completion of the email6 implementation from my point of view.  (The project won't be complete, of course, until the code becomes non-provisional, hopefully in 3.5.)
msg196825 - (view) Author: Stephen J. Turnbull (sjt) Date: 2013-09-03 07:37
I'm thinking this may be overengineering, but I may as well post it and find out for sure. :-)  Is it worth encapsulating MIME types?  They're "really" pairs as far as mail handling applications are concerned, but they have a string representation.  So

MacPorts 16:29$ python3.3
Python 3.3.2 (default, May 21 2013, 11:48:51) 
>>> from collections import namedtuple
>>> class MIMEType(namedtuple('MIMETYPE', 'type subtype')):
...  def __str__(self):
...   return "{0}/{1}".format(self.type, self.subtype)
... 
>>> mt = MIMEType('text', 'plain')
>>> str(mt)
'text/plain'
>>> t, s = mt
>>> print('type =', t, 'subtype =', s)
type = text subtype = plain
>>> 

Obviously there needs to be a constructor that handles the 'type/sub' represention.
msg196847 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-09-03 14:04
It's an interesting thought.  It bothered me to be handling them as pure strings when writing the code.  It just felt wrong somehow :)
msg196864 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2013-09-03 18:59
On Sep 03, 2013, at 07:37 AM, Stephen J. Turnbull wrote:

>I'm thinking this may be overengineering, but I may as well post it and find
>out for sure. :-) Is it worth encapsulating MIME types?  They're "really"
>pairs as far as mail handling applications are concerned, but they have a
>string representation.

Neat idea.
msg199344 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-10-09 21:12
Updating the patch to address Stephen's review comments (thanks, Stephen!).  The biggest change is adding a MIMEPart class, and renaming MIMEMessage to EmailMessage.  Other significant changes are: only moving 'Content-*' headers in 'make' methods, adding 'clear' and 'clear_content' methods (and calling clear_content in the 'make' methods), and raising a TypeError if set_content is called on a multipart.

The documentation is complete, but not completely proofread/edited.  I can always finish that after the Beta if I don't get to it before (though I expect to).  There are probably some missing docstrings as well; same comment applies :).

I have not addressed the MIMEType idea.  I will deal with that as a separate issue (and not for 3.4), since it has implications throughout the package, not just in the code I'm enhancing.

I think this is ready for commit review, assuming I haven't forgotten anything.  (I'll close the earlier issues.)
msg199535 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-10-12 02:45
Final doc edits done.  I will commit this next week if there are no objections, in order to get it in to alpha 4.
msg199625 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-10-12 21:41
Updated patch to address Serhiy's review comments.  Also noticed a bug and fixed it, adding a new 'is_attachment' attribute to EmailMessage/MIMEPart to do so.
msg200105 - (view) Author: Roundup Robot (python-dev) Date: 2013-10-17 02:53
New changeset 6d12285e250b by R David Murray in branch 'default':
#18891: Complete new provisional email API.
http://hg.python.org/cpython/rev/6d12285e250b
msg200106 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-10-17 03:33
nice!  Thanks for doing this.
msg200129 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-10-17 14:15
Thanks everyone for the reviews.  I've opened up a new issue for Stephen's mimetype object suggestion (issue 19280).

I'm still planning to add some examples to the docs, so I'm going to leave this open until I do that, but I wanted to get the code itself into the next alpha.
msg209925 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-02-01 22:50
Opened issue 20477 with the proposed examples.
History
Date User Action Args
2014-02-01 22:50:01r.david.murraysetstatus: open -> closed

messages: + msg209925
stage: commit review -> resolved
2013-10-17 14:15:31r.david.murraysetmessages: + msg200129
2013-10-17 03:54:07Arfreversettitle: Master patch for content manager addtion to email package. -> Master patch for content manager addition to email package
2013-10-17 03:33:15eric.snowsetnosy: + eric.snow
messages: + msg200106
2013-10-17 02:53:27python-devsetnosy: + python-dev
messages: + msg200105
2013-10-12 21:41:42r.david.murraysetfiles: + master_content_manager.patch

messages: + msg199625
2013-10-12 02:45:39r.david.murraysetfiles: + master_content_manager.patch

messages: + msg199535
2013-10-09 21:45:09r.david.murraylinkissue18890 superseder
2013-10-09 21:44:23r.david.murraylinkissue18860 superseder
2013-10-09 21:43:12r.david.murraylinkissue18785 superseder
2013-10-09 21:12:16r.david.murraysetfiles: + master_content_manager.patch

messages: + msg199344
stage: patch review -> commit review
2013-09-03 18:59:56barrysetmessages: + msg196864
2013-09-03 14:04:30r.david.murraysetmessages: + msg196847
2013-09-03 07:37:53sjtsetnosy: + sjt
messages: + msg196825
2013-08-31 16:17:16serhiy.storchakasetnosy: + serhiy.storchaka
2013-08-31 03:10:03r.david.murraycreate