Ok, never mind on the problem with re, I don't know why I couldln't figure that out before, I just didn't look hard enough. Although it still doesn't work. Here is what I have now.
--- /u1/mailman1/Mailman/Handlers/Decorate.py 2006-02-24 17:31:06.000000000 -0700 +++ Decorate.py 2006-05-11 12:14:22.000000000 -0600 @@ -20,6 +20,7 @@ from types import ListType from email.MIMEText import MIMEText +import re from Mailman import mm_cfg from Mailman import Utils from Mailman import Errors @@ -66,6 +67,15 @@ header = decorate(mlist, mlist.msg_header, 'non-digest header', d) footer = decorate(mlist, mlist.msg_footer, 'non-digest footer', d) # Escape hatch if both the footer and header are empty + + sender = msgdata.get('original_sender', msg.get_sender()) + if sender == '<email-address>': + footer = "THIS IS A GATEWAY MESSAGE" + + pl = msg.get_payload(decode=True) + re.sub('AZ', 'new text', pl) + msg.set_payload(pl) + if not header and not footer: return # Be MIME smart here. We only attach the header and footer by -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rob Jackson Sent: Thursday, May 11, 2006 12:07 PM To: 'Mark Sapiro'; mailman-users@python.org Subject: Re: [Mailman-Users] Custom footer based on sender's email I was aware of the if not header and not footer: return And made sure that wasn't a problem. But it seems I was probably exiting out someplace else. I used to be getting an error when I had it other places, and then when I moved it to the end, the error went away, well it is back now that I am actualy hitting the code before it exits. Here is my error. Thanks for helping out with my ignorance. "May 11 11:54:49 2006 (11951) Uncaught runner exception: global name 're' is not defined" What is the best way to define 're' I have tried looking at other examples throught the program and have been unable to determine how I need to do this. Thanks -Rob -----Original Message----- From: Mark Sapiro [mailto:[EMAIL PROTECTED] Sent: Thursday, May 11, 2006 11:46 AM To: Rob Jackson; mailman-users@python.org Subject: RE: [Mailman-Users] Custom footer based on sender's email Rob Jackson wrote: > >Here it is. > >+++ /u1/mailman/Mailman/Handlers/Decorate.py 2006-05-10 >11:36:43.000000000 -0600 >@@ -188,6 +188,12 @@ > del msg['content-disposition'] > msg['Content-Type'] = 'multipart/mixed' > >+ #Testing to replace footer >+ pl = msg.get_payload(decode=True) >+ re.sub('AZ', 'new text', pl) >+ msg.set_payload(pl) >+ >+ > > def decorate(mlist, template, what, extradict={}): Elvis has left the building... I.e. putting the code there will only get those messages in which the mailman header/footer has been added as a separate mime part to a message not already multipart/mixed. Starting from the top of Decorate.process() we have several exits: # Escape hatch if both the footer and header are empty if not header and not footer: return If there is no defined msg_header or msg_footer, we leave. # If we couldn't add the header or footer in a less intrusive way, we can # at least do it by MIME encapsulation. We want to keep as much of the # outer chrome as possible. if not wrap: return If we have managed to add the header and/or footer to a text/plain message, or if the message was already multipart/mixed and we added the header and/or footer as separate mime parts, we are done and leave here. The only thing that gets beyond here is the case where we create a new multipart/mixed 'wrapper' with header and/or footer parts and the original message as a message/rfc822 part. You first have to see whether or not you have msg_header and or msg_footer for the list, and also what the structure of the incoming message is. In the simplest case of a single part text/plain message, you could add the three lines just prior to # Escape hatch if both the footer and header are empty if not header and not footer: return -- Mark Sapiro <[EMAIL PROTECTED]> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan ------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/robertj%40linux4free.co m Security Policy: http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp ------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp