\f
-class Image(MIMEBase.MIMEBase):
+class MIMEImage(MIMEBase.MIMEBase):
"""Class for generating image/* type MIME documents."""
- def __init__(self, _imagedata, _minor=None,
+ def __init__(self, _imagedata, _subtype=None,
_encoder=Encoders.encode_base64, **_params):
"""Create an image/* type MIME document.
_imagedata is a string containing the raw image data. If this data
can be decoded by the standard Python `imghdr' module, then the
subtype will be automatically included in the Content-Type: header.
- Otherwise, you can specify the specific image subtype via the _minor
+ Otherwise, you can specify the specific image subtype via the _subtype
parameter.
_encoder is a function which will perform the actual encoding for
constructor, which turns them into parameters on the Content-Type:
header.
"""
- if _minor is None:
- _minor = imghdr.what(None, _imagedata)
- if _minor is None:
- raise TypeError, 'Could not guess image _minor type'
- MIMEBase.MIMEBase.__init__(self, 'image', _minor, **_params)
+ if _subtype is None:
+ _subtype = imghdr.what(None, _imagedata)
+ if _subtype is None:
+ raise TypeError, 'Could not guess image MIME subtype'
+ MIMEBase.MIMEBase.__init__(self, 'image', _subtype, **_params)
self.set_payload(_imagedata)
_encoder(self)
--- /dev/null
+# Copyright (C) 2001 Python Software Foundation
+# Author: barry@zope.com (Barry Warsaw)
+
+"""Class representing message/* MIME documents.
+"""
+
+import Message
+import MIMEBase
+
+
+\f
+class MIMEMessage(MIMEBase.MIMEBase):
+ """Class representing message/* MIME documents."""
+
+ def __init__(self, _msg, _subtype='rfc822'):
+ """Create a message/* type MIME document.
+
+ _msg is a message object and must be an instance of Message, or a
+ derived class of Message, otherwise a TypeError is raised.
+
+ Optional _subtype defines the subtype of the contained message. The
+ default is "rfc822" (this is defined by the MIME standard, even though
+ the term "rfc822" is technically outdated by RFC 2822).
+ """
+ MIMEBase.MIMEBase.__init__(self, 'message', _subtype)
+ if not isinstance(_msg, Message.Message):
+ raise TypeError, 'Argument is not an instance of Message'
+ self.set_payload(_msg)
\f
-class Text(MIMEBase.MIMEBase):
+class MIMEText(MIMEBase.MIMEBase):
"""Class for generating text/* type MIME documents."""
- def __init__(self, _text, _minor='plain', _charset='us-ascii',
+ def __init__(self, _text, _subtype='plain', _charset='us-ascii',
_encoder=encode_7or8bit):
"""Create a text/* type MIME document.
_text is the string for this message object. If the text does not end
in a newline, one is added.
- _minor is the minor content type, defaulting to "plain".
+ _subtype is the MIME sub content type, defaulting to "plain".
_charset is the character set parameter added to the Content-Type:
header. This defaults to "us-ascii".
but it does set Content-Transfer-Encoding: to either `7bit' or `8bit'
as appropriate.
"""
- MIMEBase.MIMEBase.__init__(self, 'text', _minor,
+ MIMEBase.MIMEBase.__init__(self, 'text', _subtype,
**{'charset': _charset})
if _text and _text[-1] <> '\n':
_text += '\n'
+++ /dev/null
-# Copyright (C) 2001 Python Software Foundation
-# Author: barry@zope.com (Barry Warsaw)
-
-"""Class for generating message/rfc822 MIME documents.
-"""
-
-import Message
-import MIMEBase
-
-
-\f
-class MessageRFC822(MIMEBase.MIMEBase):
- """Class for generating message/rfc822 MIME documents."""
-
- def __init__(self, _msg):
- """Create a message/rfc822 type MIME document.
-
- _msg is a message object and must be an instance of Message, or a
- derived class of Message, otherwise a TypeError is raised.
- """
- MIMEBase.MIMEBase.__init__(self, 'message', 'rfc822')
- if not isinstance(_msg, Message.Message):
- raise TypeError, 'Argument is not an instance of Message'
- self.set_payload(_msg)