mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Added section for MimeWriter, contributed by Christopher Petrilli
<petrilli@amber.org>. This spells the end of another whole section in the undoc chapter!
This commit is contained in:
parent
f7bf3b2b06
commit
28bc711f5f
3 changed files with 76 additions and 8 deletions
|
@ -186,6 +186,7 @@ add new extensions to Python and how to embed it in other applications.
|
|||
\input{libformatter}
|
||||
\input{librfc822}
|
||||
\input{libmimetools}
|
||||
\input{libmimewriter}
|
||||
\input{libmultifile}
|
||||
\input{libbinhex}
|
||||
\input{libuu}
|
||||
|
|
75
Doc/lib/libmimewriter.tex
Normal file
75
Doc/lib/libmimewriter.tex
Normal file
|
@ -0,0 +1,75 @@
|
|||
\section{\module{MimeWriter} ---
|
||||
Generic MIME file writer}
|
||||
|
||||
\declaremodule{standard}{MimeWriter}
|
||||
|
||||
\modulesynopsis{Generic MIME file writer.}
|
||||
\sectionauthor{Christopher G. Petrilli}{petrilli@amber.org}
|
||||
|
||||
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.
|
||||
|
||||
\begin{classdesc}{MimeWriter}{fp}
|
||||
Return a new instance of the \class{MimeWriter} class. The only
|
||||
argument passed, \var{fp}, is a file object to be used for
|
||||
writing. Note that a \class{StringIO} object could also be used.
|
||||
\end{classdesc}
|
||||
|
||||
|
||||
\subsection{MimeWriter Objects \label{MimeWriter-objects}}
|
||||
|
||||
|
||||
\class{MimeWriter} instances have the following methods:
|
||||
|
||||
\begin{methoddesc}{addheader}{key, value\optional{, prefix}}
|
||||
Add a header line to the MIME message. The \var{key} is the name of
|
||||
the header, where the \var{value} obviously provides the value of the
|
||||
header. The optional argument \var{prefix} determines where the header
|
||||
is inserted; \samp{0} means append at the end, \samp{1} is insert at
|
||||
the start. The default is to append.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{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.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{startbody}{ctype\optional{, plist\optional{, 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
|
||||
\var{ctype}, and the optional parameter \var{plist} provides
|
||||
additional parameters for the content-type declaration. \var{prefix}
|
||||
functions as in \method{addheader()} except that the default is to
|
||||
insert at the start.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{startmultipartbody}{subtype\optional{,
|
||||
boundary\optional{, plist\optional{, 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 \var{subtype} provides the mutlipart subtype,
|
||||
\var{boundary} may provide a user-defined boundary specification, and
|
||||
\var{plist} provides optional parameters for the subtype.
|
||||
\var{prefix} functions as in \method{startbody()}. Subparts should be
|
||||
created using \method{nextpart()}.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{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
|
||||
\method{startmultipartbody()} before using \method{nextpart()}.
|
||||
\end{methoddesc}
|
||||
|
||||
\begin{methoddesc}{lastpart}{}
|
||||
This is used to designate the last part of a multipart message, and
|
||||
should \emph{always} be used when writing multipart messages.
|
||||
\end{methoddesc}
|
|
@ -30,14 +30,6 @@ This is a package rather than a module.
|
|||
\end{description}
|
||||
|
||||
|
||||
\section{Stuff useful to a lot of people, including the CGI crowd}
|
||||
|
||||
\begin{description}
|
||||
\item[MimeWriter.py]
|
||||
--- Generic MIME writer
|
||||
\end{description}
|
||||
|
||||
|
||||
\section{Miscellaneous useful utilities}
|
||||
|
||||
Some of these are very old and/or not very robust; marked with ``hmm''.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue