Stephen J. Turnbull wrote:

>Mark Sapiro writes:
>
> > This would add %(poster_name)s to the replacements available for
> > msg_header and msg_footer, and its value would be the real name part
> > of the From: address of the original post or the empty string if there
> > wasn't a real name in the From:
>
>Would it be possible to get the full name from the list object
>(assuming the poster is a subscriber and that the full name is there)?


Sure. A somewhat more complete handler (and perhaps more Pythonic as
well) would be:


from email.Utils import parseaddr
def process(mlist, msg, msgdata):
    poster_name, addrs = parseaddr(msg['from'])
    if not poster_name and mlist.isMember(addrs):
        poster_name = mlist.getMemberName(address) or ''
    msgdata.setdefault('decoration-data', {}).update(
                                  poster_name=poster_name)


Notes:
  This prefers the name in the From header over the list member's real
name. That could be reversed.
  The dictionary update(poster_name=poster_name) syntax requires Python
2.4 or later. For older Python, this would be update(
                             {'poster_name': poster_name})

-- 
Mark Sapiro <[email protected]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

------------------------------------------------------
Mailman-Users mailing list [email protected]
http://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: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to