Barry Warsaw | 2f514a8 | 2002-06-01 05:59:12 +0000 | [diff] [blame] | 1 | # Copyright (C) 2002 Python Software Foundation |
| 2 | # Author: barry@zope.com (Barry Warsaw) |
| 3 | |
| 4 | """Base class for MIME multipart/* type messages. |
| 5 | """ |
| 6 | |
| 7 | from email import MIMEBase |
| 8 | |
| 9 | |
| 10 | |
| 11 | class MIMEMultipart(MIMEBase.MIMEBase): |
| 12 | """Base class for MIME multipart/* type messages.""" |
| 13 | |
| 14 | def __init__(self, _subtype='mixed', boundary=None, *_subparts, **_params): |
| 15 | """Creates a multipart/* type message. |
| 16 | |
| 17 | By default, creates a multipart/mixed message, with proper |
| 18 | Content-Type: and MIME-Version: headers. |
| 19 | |
| 20 | _subtype is the subtype of the multipart content type, defaulting to |
| 21 | `mixed'. |
| 22 | |
| 23 | boundary is the multipart boundary string. By default it is |
| 24 | calculated as needed. |
| 25 | |
| 26 | _subparts is a sequence of initial subparts for the multipart. It |
| 27 | must be possible to convert this sequence to a list. You can always |
| 28 | attach new subparts to the message by using the attach() method. |
| 29 | |
| 30 | Additional parameters for the Content-Type: header are taken from the |
| 31 | keyword arguments (or passed into the _params argument). |
| 32 | """ |
| 33 | MIMEBase.MIMEBase.__init__(self, 'multipart', _subtype, **params) |
| 34 | self.attach(*list(_subparts)) |