summaryrefslogtreecommitdiffstats
path: root/Lib/email/policy.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-10-17 02:48:40 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-10-17 02:48:40 (GMT)
commit3da240fd01e02a31e516847ba865a9f56d7cfcbc (patch)
tree056628df84b2e949fb793d75235e38766a16fbcc /Lib/email/policy.py
parent1a1628819779110854d4e1ab490db2cab80e26b4 (diff)
downloadcpython-3da240fd01e02a31e516847ba865a9f56d7cfcbc.zip
cpython-3da240fd01e02a31e516847ba865a9f56d7cfcbc.tar.gz
cpython-3da240fd01e02a31e516847ba865a9f56d7cfcbc.tar.bz2
#18891: Complete new provisional email API.
This adds EmailMessage and, MIMEPart subclasses of Message with new API methods, and a ContentManager class used by the new methods. Also a new policy setting, content_manager. Patch was reviewed by Stephen J. Turnbull and Serhiy Storchaka, and reflects their feedback. I will ideally add some examples of using the new API to the documentation before the final release.
Diffstat (limited to 'Lib/email/policy.py')
-rw-r--r--Lib/email/policy.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/email/policy.py b/Lib/email/policy.py
index 38e88af..f0b20f4 100644
--- a/Lib/email/policy.py
+++ b/Lib/email/policy.py
@@ -5,6 +5,7 @@ code that adds all the email6 features.
from email._policybase import Policy, Compat32, compat32, _extend_docstrings
from email.utils import _has_surrogates
from email.headerregistry import HeaderRegistry as HeaderRegistry
+from email.contentmanager import raw_data_manager
__all__ = [
'Compat32',
@@ -58,10 +59,22 @@ class EmailPolicy(Policy):
special treatment, while all other fields are
treated as unstructured. This list will be
completed before the extension is marked stable.)
+
+ content_manager -- an object with at least two methods: get_content
+ and set_content. When the get_content or
+ set_content method of a Message object is called,
+ it calls the corresponding method of this object,
+ passing it the message object as its first argument,
+ and any arguments or keywords that were passed to
+ it as additional arguments. The default
+ content_manager is
+ :data:`~email.contentmanager.raw_data_manager`.
+
"""
refold_source = 'long'
header_factory = HeaderRegistry()
+ content_manager = raw_data_manager
def __init__(self, **kw):
# Ensure that each new instance gets a unique header factory