[Mailman-Developers] handler to auto detach attachment and link it to a website keeping html

Mark Sapiro mark at msapiro.net
Sat Apr 19 20:24:59 CEST 2014


On 04/18/2014 11:57 PM, Sylvain Viart wrote:
> 
> Le 18/04/2014 22:30, Mark Sapiro a écrit :

>> should be ---------------
>>
>>                  clip = MIMEImage(xxx, 'png')
> 
> Yeah, I know. But I've embedded the base64 txt data of the clip image in
> the handler.py's code.
> So I don't need to manage an external file for the clip. Could MIMEImage
> handle internal data as well?
> 
> It seems extra effort, to mime64 decode and let MIMEImage reencode it,
> right?


You don't have to do that. If xxx is the base64 encoded image data, all
you need is

    clip = MIMEImage(xxx, 'png', _encoder=email.encoders.encode_noop)
    clip['Content-Transfer-Encoding'] = 'base64'

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the Mailman-Developers mailing list