RE: [Zope] change to MimeWriter to add "MIME-Version: 1.0"
-----Original Message----- From: Pate, Clarence T [mailto:Clarence.Pate@bridge.bellsouth.com] Sent: Wednesday, October 06, 1999 11:09 AM To: zope@zope.org Subject: [Zope] change to MimeWriter to add "MIME-Version: 1.0"
If anyone is interested in the "MIME-Version header", I have played with the mime stuff and read rfc1341 to understand better how this stuff works. I am enclosing a subset of MimeWriter.py which will allow the functions to put the "MIME-Version: 1.0" header in the correct place. I would like to warn everyone that I am not a python programmer, and there might be a better way to do this.
Note that Mimewriter is a standard python module, not a part of Zope. You should submit your patch to the apropriate module author or to the http://www.python.org/python-bugs section of the python site. Thanks for the patch! -Michel
=-> =->Note that Mimewriter is a standard python module, not a part of Zope. =->You should submit your patch to the apropriate module author or to the =->http://www.python.org/python-bugs section of the python site. =-> =->Thanks for the patch! =-> =->-Michel =-> Michael, I sent a message to Guido, and he suggested something that was much better (I really should not have bothered him with this minor problem.) All that was necessary is to change "MimeTools.py". Basically, I added a parameter to the mime tag, <!--#mime version=true-->. Since I am not a python programmer, somebody should verify that this does what I think it does!?! I have included the subset of MimeTools.py that I changed. name='mime' blockContinuations=('boundary',) encode=None """I added version=None. I guess this is like a global variable. I am not sure if this is necessary""" version=None def __init__(self, blocks): self.sections = [] for tname, args, section in blocks: """I added the parameter version""" args = parse_params(args, type=None, disposition=None, encode=None, name=None, version=None) has_key=args.has_key if has_key('type'): type = args['type'] else: type = 'application/octet-stream' if has_key('disposition'): disposition = args['disposition'] else: disposition = '' if has_key('encode'): encode = args['encode'] else: encode = 'base64' if has_key('name'): name = args['name'] else: name = '' """I added this. I believe it checks for any value, if no value set to ''""" if has_key('version'): version = args['version'] else: version = '' if encode not in \ ('base64', 'quoted-printable', 'uuencode', 'x-uuencode', 'uue', 'x-uue', '7bit'): raise MIMEError, ( 'An unsupported encoding was specified in tag') self.sections.append((type, disposition, encode, name, version, section.blocks)) def render(self, md): contents=[] mw = MimeWriter(StringIO()) """I added this. If version exists, add the header to 'outer'. This only provides for version 1.0, maybe this should be a variable that is actually passed if there are new future version numbers. """ for x in self.sections: t, d, e, n, v, b = x if v: outer = mw.addheader("MIME-Version", "1.0", prefix=1) outer = mw.startmultipartbody('mixed') Thanks for the help! Clarence T. Pate
participants (2)
-
Michel Pelletier -
Pate, Clarence T