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