Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # Copyright (C) 2002-2004 Python Software Foundation |
2 | # Author: Barry Warsaw | |
3 | # Contact: email-sig@python.org | |
4 | ||
5 | """Base class for MIME multipart/* type messages.""" | |
6 | ||
7 | from email import MIMEBase | |
8 | ||
9 | ||
10 | \f | |
11 | class MIMEMultipart(MIMEBase.MIMEBase): | |
12 | """Base class for MIME multipart/* type messages.""" | |
13 | ||
14 | def __init__(self, _subtype='mixed', boundary=None, _subparts=None, | |
15 | **_params): | |
16 | """Creates a multipart/* type message. | |
17 | ||
18 | By default, creates a multipart/mixed message, with proper | |
19 | Content-Type and MIME-Version headers. | |
20 | ||
21 | _subtype is the subtype of the multipart content type, defaulting to | |
22 | `mixed'. | |
23 | ||
24 | boundary is the multipart boundary string. By default it is | |
25 | calculated as needed. | |
26 | ||
27 | _subparts is a sequence of initial subparts for the payload. It | |
28 | must be an iterable object, such as a list. You can always | |
29 | attach new subparts to the message by using the attach() method. | |
30 | ||
31 | Additional parameters for the Content-Type header are taken from the | |
32 | keyword arguments (or passed into the _params argument). | |
33 | """ | |
34 | MIMEBase.MIMEBase.__init__(self, 'multipart', _subtype, **_params) | |
35 | if _subparts: | |
36 | for p in _subparts: | |
37 | self.attach(p) | |
38 | if boundary: | |
39 | self.set_boundary(boundary) |