[Mailman-Users] private lists with real name signatures
Mark Sapiro
mark at msapiro.net
Wed May 26 18:55:49 CEST 2010
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 <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-Users
mailing list