[Mailman-Developers] attachments to links :-)
Michael Meltzer
mjm@michaelmeltzer.com
Tue, 15 Oct 2002 14:57:42 -0400
chutzpah works for me, Thank You Thank You, My NewYorker is coming out :-)
I just took a shot at patching against the CVS, you been a busy camper :-) dispose is a nice touch and stops "where did it go
questions" . I need tonight to line my stuff up, I gave you a quick rundown below, forgive me, python is not my first langue :-) I
am pretty sure I can have a patch for MimeDel.py and Private.py, the template's I am clue less :-), I understand no promises, just
wanted to get back to you, see if their is interest, Or find out my lame code it not up to standards :-)
MJM
But in English:
For MimeDel.py
1)
from Mailman.Handlers.Scrubber import save_attachment
from time import strftime
2)
in filter_parts add the call to make_attachment, by it changing the mtype/ctype it stays out of the way of the filtering code, also
need to insert it near the top of the code to catch a single message of these mime types.
def make_attachment(mlist, subpart):
! #should be set from mlist, work in progress
! #BTW this will act real stupid with mulipart, it need the real object not the house keeping
! attach_filter = ['image/bmp', 'image/jpeg', 'image/tiff', 'image/gif', 'image/png', 'image/pjpeg', 'image/x-png',
'image/x-wmf']
! ctype = subpart.get_type('text/plain')
! mtype = subpart.get_main_type('text')
! if ctype in attach_filter or mtype in attach_filter:
! cctype = subpart.get_type()
! #size is off, just could not stand to call decode to correct, might just take off 20% and be done
! size = len(subpart.get_payload())
! desc = subpart.get('content-description', (_('not available')))
! filename = subpart.get_filename(_('not available'))
! url = save_attachment(mlist, subpart, strftime("attch/%Y%m/%d"))
! del subpart['content-type']
! del subpart['content-transfer-encoding']
! del subpart['content-disposition']
! del subpart['content-description']
! subpart.add_header('Content-Type', 'text/plain', charset='us-ascii')
! subpart.add_header('Content-Transfer-Encoding', '7bit')
! subpart.add_header('Content-disposition', 'inline')
! subpart.set_payload(_("""\
! Name: %(filename)s Type: %(cctype)s Size: %(size)d bytes Desc: %(desc)s
! Url: %(url)s
! """))
! return 1
! else:
! return 0
!
!
3)
attach_filter should be on mlist and part of the filter_content template
4)their is a problem in private.py(I think this will show for some of the scrubber functionality too), it dose not return the mime
type to the browser for the extended types, might be a good idea to confirm it with the types from attach_filter for good security.
----- Original Message -----
From: "Barry A. Warsaw" <barry@python.org>
To: "Michael Meltzer" <mjm@michaelmeltzer.com>
Cc: <mailman-developers@python.org>
Sent: Tuesday, October 15, 2002 2:01 PM
Subject: Re: [Mailman-Developers] attachments to links :-)
>
> >>>>> "MM" == Michael Meltzer <mjm@michaelmeltzer.com> writes:
>
> MM> Barry you seem in a good mood today. Figured no good deed
> MM> should so unpunished :-) I try to pitch it again :-)
>
> I love the chutzpah! We try to have the same attitude in the Python
> world too. :)
>
> MM> Any chance to get attachments to links in 2.1b4, very good
> MM> stuff :-)
>
> Remind me again, is there a SF patch waiting to be applied? Not that
> I'm promising to add it...
>
> MM> I can not offer a soybean farm but I always like growing
> MM> mushroom better, They do best in old mines, completely in the
> MM> dark and you only concern is how high and fresh the sh-t is
> MM> :-)
>
> My patent is pending on hallucinogenic soybeans. A little wasabi
> coating and dude, duuuudde! Taste, good for you, and hours of
> entertainment in each bag(gie). I have a very special XEmacs
> font-lock color scheme just for when the test batches roll out of the
> oven.
>
> -Barry