mime types
[software/python-on-guile.git] / modules / language / python / module / email / mime / message.py
1 module(email,mime,message)
2
3 # Copyright (C) 2001-2006 Python Software Foundation
4 # Author: Barry Warsaw
5 # Contact: email-sig@python.org
6
7 """Class representing message/* MIME documents."""
8
9 __all__ = ['MIMEMessage']
10
11 import email.message as message
12 from email.mime.nonmultipart import MIMENonMultipart
13
14
15
16 class MIMEMessage(MIMENonMultipart):
17 """Class representing message/* MIME documents."""
18
19 def __init__(self, _msg, _subtype='rfc822', *, policy=None):
20 """Create a message/* type MIME document.
21
22 _msg is a message object and must be an instance of Message, or a
23 derived class of Message, otherwise a TypeError is raised.
24
25 Optional _subtype defines the subtype of the contained message. The
26 default is "rfc822" (this is defined by the MIME standard, even though
27 the term "rfc822" is technically outdated by RFC 2822).
28 """
29 MIMENonMultipart.__init__(self, 'message', _subtype, policy=policy)
30 if not isinstance(_msg, message.Message):
31 raise TypeError('Argument is not an instance of Message')
32 # It's convenient to use this base class method. We need to do it
33 # this way or we'll get an exception
34 message.Message.attach(self, _msg)
35 # And be sure our default type is set correctly
36 self.set_default_type('message/rfc822')