On 04/15/2014 09:08 AM, Sylvain Viart wrote: > > I borrowed a code from Mailman/Handlers/MimeDel.py > > def reset_payload(msg, txt, fname, url): > # Reset payload of msg to contents of subpart, and fix up content > headers > msg.set_payload(txt) > del msg['content-type'] > del msg['content-transfer-encoding'] > del msg['content-disposition'] > del msg['content-description'] > > msg.add_header('X-Mailman-Part', 'Attachment-moved', url=url) > msg.add_header('Content-Type', 'text/plain', charset='UTF-8', > name=fname) > msg.add_header('Content-Transfer-Encoding', '8bit') > msg.add_header('Content-Disposition', 'attachment', filename=fname) > msg.add_header('Content-Description', "Attachment-moved by Mailman") > > > Is it the correct way to use email.message.Message > <https://docs.python.org/2/library/email.message.html> > in order to replace an attachment with a dummy text file containing the > link?
It isn't really important in this case, but 'msg' is a Mailman.Message.Message instance. Mailman.Message.Message is a subclass of email.message.Message, but it mostly just adds a few methods. It doesn't change the behavior of any methods documented at <https://docs.python.org/2/library/email.html>. You can use code like the above to manipulate the sub-part headers, but > No other way to, remove all header in oneshot, or replace with a fresh > parsed attachment? if you wish to remove the subpart all together you can just 'del' it and use methods documented at <https://docs.python.org/2/library/email.mime.html> to create new sub-parts and use the Message.attach() method to attach them. > But I will publish the source. > > Is there a preferred repository or procedure? Yes. This will change in the future, but the preferred method is to create a bzr branch containing your change, register at launchpad and then push your branch to <https://code.launchpad.net/mailman>. But whatever you do, post a note here so we know. -- Mark Sapiro <m...@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan ------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org