summaryrefslogtreecommitdiffstats
path: root/Doc/library/mimewriter.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-08-15 14:28:01 (GMT)
committerGeorg Brandl <georg@python.org>2007-08-15 14:28:01 (GMT)
commit8ec7f656134b1230ab23003a94ba3266d7064122 (patch)
treebc730d5fb3302dc375edd26b26f750d609b61d72 /Doc/library/mimewriter.rst
parentf56181ff53ba00b7bed3997a4dccd9a1b6217b57 (diff)
downloadcpython-8ec7f656134b1230ab23003a94ba3266d7064122.zip
cpython-8ec7f656134b1230ab23003a94ba3266d7064122.tar.gz
cpython-8ec7f656134b1230ab23003a94ba3266d7064122.tar.bz2
Move the 2.6 reST doc tree in place.
Diffstat (limited to 'Doc/library/mimewriter.rst')
-rw-r--r--Doc/library/mimewriter.rst84
1 files changed, 84 insertions, 0 deletions
diff --git a/Doc/library/mimewriter.rst b/Doc/library/mimewriter.rst
new file mode 100644
index 0000000..cf93473
--- /dev/null
+++ b/Doc/library/mimewriter.rst
@@ -0,0 +1,84 @@
+:mod:`MimeWriter` --- Generic MIME file writer
+==============================================
+
+.. module:: MimeWriter
+ :synopsis: Write MIME format files.
+
+.. sectionauthor:: Christopher G. Petrilli <petrilli@amber.org>
+
+
+.. deprecated:: 2.3
+ The :mod:`email` package should be used in preference to the :mod:`MimeWriter`
+ module. This module is present only to maintain backward compatibility.
+
+This module defines the class :class:`MimeWriter`. The :class:`MimeWriter`
+class implements a basic formatter for creating MIME multi-part files. It
+doesn't seek around the output file nor does it use large amounts of buffer
+space. You must write the parts out in the order that they should occur in the
+final file. :class:`MimeWriter` does buffer the headers you add, allowing you
+to rearrange their order.
+
+
+.. class:: MimeWriter(fp)
+
+ Return a new instance of the :class:`MimeWriter` class. The only argument
+ passed, *fp*, is a file object to be used for writing. Note that a
+ :class:`StringIO` object could also be used.
+
+
+.. _mimewriter-objects:
+
+MimeWriter Objects
+------------------
+
+:class:`MimeWriter` instances have the following methods:
+
+
+.. method:: MimeWriter.addheader(key, value[, prefix])
+
+ Add a header line to the MIME message. The *key* is the name of the header,
+ where the *value* obviously provides the value of the header. The optional
+ argument *prefix* determines where the header is inserted; ``0`` means append
+ at the end, ``1`` is insert at the start. The default is to append.
+
+
+.. method:: MimeWriter.flushheaders()
+
+ Causes all headers accumulated so far to be written out (and forgotten). This is
+ useful if you don't need a body part at all, e.g. for a subpart of type
+ :mimetype:`message/rfc822` that's (mis)used to store some header-like
+ information.
+
+
+.. method:: MimeWriter.startbody(ctype[, plist[, prefix]])
+
+ Returns a file-like object which can be used to write to the body of the
+ message. The content-type is set to the provided *ctype*, and the optional
+ parameter *plist* provides additional parameters for the content-type
+ declaration. *prefix* functions as in :meth:`addheader` except that the default
+ is to insert at the start.
+
+
+.. method:: MimeWriter.startmultipartbody(subtype[, boundary[, plist[, prefix]]])
+
+ Returns a file-like object which can be used to write to the body of the
+ message. Additionally, this method initializes the multi-part code, where
+ *subtype* provides the multipart subtype, *boundary* may provide a user-defined
+ boundary specification, and *plist* provides optional parameters for the
+ subtype. *prefix* functions as in :meth:`startbody`. Subparts should be created
+ using :meth:`nextpart`.
+
+
+.. method:: MimeWriter.nextpart()
+
+ Returns a new instance of :class:`MimeWriter` which represents an individual
+ part in a multipart message. This may be used to write the part as well as
+ used for creating recursively complex multipart messages. The message must first
+ be initialized with :meth:`startmultipartbody` before using :meth:`nextpart`.
+
+
+.. method:: MimeWriter.lastpart()
+
+ This is used to designate the last part of a multipart message, and should
+ *always* be used when writing multipart messages.
+