blob: 001c8a8b28c850a06d02edd0242de49645091718 [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
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 """
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)