~erica-wolfe/systers/wishlist

« back to all changes in this revision

Viewing changes to Mailman/DlistUtils.py

  • Committer: Erica Wolfe
  • Date: 2010-07-19 23:03:57 UTC
  • Revision ID: erica.wolfe@gmail.com-20100719230357-dd1dy45elddlv0uk
https://bugs.launchpad.net/systers/+bug/386133
https://bugs.launchpad.net/systers/+bug/324406

The two bugs are small issues with unsubscribing.  To resolve these issues, 
I split the Handler/Dlists.py into two files, Handlers/PreprocessDlists and 
Handlers/ProcessDlists.  Shared functions were put into DlistUtils.  Small
edits to mm_cfg.py were required to insert the new files into the handler
pipeline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
853
853
    _remove_database(listname)
854
854
    if DEBUG_MODE:
855
855
         syslog('info', "Database %s removed\n", listname)
 
856
 
 
857
#These are utility methods for the dlist handlers
 
858
 
 
859
def get_malformed_msg_txt(mlist):
 
860
    vars = dict(host=mlist.host_name, listname=mlist.internal_name())
 
861
    return "Your message was rejected because it was sent to an invalid address.  If you want to add a message to an existing conversation,send it to %(listname)s+conversation@%(host)s, replacing 'conversation' with the name of the existing conversation.  If you want to start a new conversation on %(listname)s, send your message to %(listname)s+new@%(host)s\n\n" % vars
 
862
 
 
863
def get_commands(mlist, msg):
 
864
    try:
 
865
        # To and CC could be anything, but we know x-original-to will be
 
866
        # the list address in question.
 
867
        incomingAddress = msg['X-Original-To'].split('@')[0] # strip domain
 
868
        commands = incomingAddress.split('+')[1:] # strip listname
 
869
    except Exception, e:
 
870
        raise ErrorsDlist.MalformedRequest(get_malformed_msg_txt(mlist)) 
 
871
    
 
872
    if not len(commands):
 
873
        raise ErrorsDlist.MalformedRequest(get_malformed_msg_txt(mlist))
 
874
    
 
875
    return commands