[Python-checkins] python/dist/src/Lib/email Message.py,1.14,1.15

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Mon, 08 Jul 2002 19:46:14 -0700


Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv13919/email

Modified Files:
	Message.py 
Log Message:
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.


Index: Message.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Message.py	29 Jun 2002 05:56:15 -0000	1.14
--- Message.py	9 Jul 2002 02:46:12 -0000	1.15
***************
*** 80,83 ****
--- 80,85 ----
          # Defaults for multipart messages
          self.preamble = self.epilogue = None
+         # Default content type
+         self._default_type = 'text/plain'
  
      def __str__(self):
***************
*** 395,398 ****
--- 397,420 ----
              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):