summaryrefslogtreecommitdiffstats
path: root/Lib/email/Message.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2002-07-09 02:46:12 (GMT)
committerBarry Warsaw <barry@python.org>2002-07-09 02:46:12 (GMT)
commita0c8b9d4d5fda80f82553ed91b341a531a846ab6 (patch)
tree67a5acaca67cc70ea49b2f5cab7ef4d37f411eb5 /Lib/email/Message.py
parentbb493a7039ca56e7f7471128340ad3d854da0305 (diff)
downloadcpython-a0c8b9d4d5fda80f82553ed91b341a531a846ab6.zip
cpython-a0c8b9d4d5fda80f82553ed91b341a531a846ab6.tar.gz
cpython-a0c8b9d4d5fda80f82553ed91b341a531a846ab6.tar.bz2
Add the concept of a "default type". Normally the default type is
text/plain but the RFCs state that inside a multipart/digest, the default type is message/rfc822. To preserve idempotency, we need a separate place to define the default type than the Content-Type: header. get_default_type(), set_default_type(): Accessor and mutator methods for the default type.
Diffstat (limited to 'Lib/email/Message.py')
-rw-r--r--Lib/email/Message.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/email/Message.py b/Lib/email/Message.py
index d6f59f4..5e8d32f 100644
--- a/Lib/email/Message.py
+++ b/Lib/email/Message.py
@@ -79,6 +79,8 @@ class Message:
self._charset = None
# Defaults for multipart messages
self.preamble = self.epilogue = None
+ # Default content type
+ self._default_type = 'text/plain'
def __str__(self):
"""Return the entire formatted message as a string.
@@ -395,6 +397,26 @@ class Message:
return ctype.split('/')[1]
return failobj
+ def get_default_type(self):
+ """Return the `default' content type.
+
+ Most messages have a default content type of text/plain, except for
+ messages that are subparts of multipart/digest containers. Such
+ subparts then have a default content type of message/rfc822.
+ """
+ return self._default_type
+
+ def set_default_type(self, ctype):
+ """Set the `default' content type.
+
+ ctype must be either "text/plain" or "message/rfc822". The default
+ content type is not stored in the Content-Type: header.
+ """
+ if ctype not in ('text/plain', 'message/rfc822'):
+ raise ValueError(
+ 'first arg must be either "text/plain" or "message/rfc822"')
+ self._default_type = ctype
+
def _get_params_preserve(self, failobj, header):
# Like get_params() but preserves the quoting of values. BAW:
# should this be part of the public interface?