blob: 16add2f8ca9f3aeff58006f3a460940f719a53e7 [file] [log] [blame]
Barry Warsaw2f514a82002-06-01 05:59:12 +00001# Copyright (C) 2002 Python Software Foundation
2# Author: barry@zope.com (Barry Warsaw)
3
4"""Base class for MIME multipart/* type messages.
5"""
6
7from email import MIMEBase
8
9
10
11class 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
Barry Warsawfd2e8f72002-09-30 21:24:00 +000018 Content-Type and MIME-Version headers.
Barry Warsaw2f514a82002-06-01 05:59:12 +000019
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
Barry Warsawfd2e8f72002-09-30 21:24:00 +000026 _subparts is a sequence of initial subparts for the payload. It
Barry Warsaw2f514a82002-06-01 05:59:12 +000027 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
Barry Warsawfd2e8f72002-09-30 21:24:00 +000030 Additional parameters for the Content-Type header are taken from the
Barry Warsaw2f514a82002-06-01 05:59:12 +000031 keyword arguments (or passed into the _params argument).
32 """
Barry Warsawbb493a72002-07-09 02:44:26 +000033 MIMEBase.MIMEBase.__init__(self, 'multipart', _subtype, **_params)
34 if _subparts:
35 self.attach(*list(_subparts))
36 if boundary:
37 self.set_boundary(boundary)