[Mailman-Users] custom handler

George, Harry G harry.g.george at boeing.com
Wed Feb 15 20:24:08 CET 2012


I'm stuck on the basic development cycle for "custom handlers".   Symptom is that it is remembering an early attempt and not loading the latest version of my handler.     Also, I'm now trying to use syslog (to post or to error) as a way to get/read/understand msg and msgdata -- is there a better way?

I have a list (dlms_1) that I want to use with no hint of mailman being invloved (no listnames, not "mailman").

At Mark Sapiro's recommendation, I've been looking at custom handler:
http://wiki.list.org/pages/viewpage.action?pageId=4030615

I've made a working directory within the mailman context:
/usr3/mailman/
    bin/
    Mailman/
        Handlers/
             (Custom__dlms_1.py goes here)
    custom/
         dlms_1/
             go                       #cp handler and run config_list
             custpipe__dlms_1.py      #set mlist.pipeline
             Custom__dlms_1.py        #where I'll do my work
    ...

Process:
1. Edit Custom__dlms_1.py.
2. Run "go"
3. Send email from MS outlook to dlms_1 list.
4. No response or posting, so check post and error logs
5. Nothing new in post, but erro log has
#-----------------------
  File "/usr3/mailman/Mailman/Queue/Runner.py", line 170, in _onefile
    keepqueued = self._dispose(mlist, msg, msgdata)
  File "/usr3/mailman/Mailman/Queue/IncomingRunner.py", line 130, in _dispose
    more = self._dopipeline(mlist, msg, msgdata, pipeline)
  File "/usr3/mailman/Mailman/Queue/IncomingRunner.py", line 153, in _dopipelin

    sys.modules[modname].process(mlist, msg, msgdata)
  File "/usr3/mailman/Mailman/Handlers/Custom__dlms_1.py", line 66, in process
AttributeError: 'str' object has no attribute 'append'

Feb 15 09:00:17 2012 (3662) SHUNTING: 1329325217.251622+f51327464d18dafebf2da57
ede3fbc086fd8fcc
#---------------------------
 
There is no line 66 in the current Custom_dlms_1.py.    
I did try several variations before trimming to the current skeleton.

#---go---
#=================================================
# Install handler
#=================================================
cp Custom__dlms_1.py /usr3/mailman/Mailman/Handlers

#=================================================
# Config for new pipe
#=================================================
/usr3/mailman/bin/config_list -i custpipe__dlms_1.py dlms_1

#---custpipe__dlms_1.py---
mlist.pipeline= [
    # These are the modules that do tasks common to all delivery paths.
    'SpamDetect',
    'Approve',
    'Replybot',
    'Moderate',
    'Hold',
    'MimeDel',
    'Scrubber',
    'Emergency',
    'Tagger',
    'CalcRecips',
    'AvoidDuplicates',
    'Cleanse',
    'Custom__dlms_1',    #<--- custom here
    'CleanseDKIM',
    'CookHeaders',
    # And now we send the message to the digest mbox file, and to the arch and
    # news queues.  Runners will provide further processing of the message,
    # specific to those delivery paths.
    'ToDigest',
    'ToArchive',
    'ToUsenet',
    # Now we'll do a few extra things specific to the member delivery
    # (outgoing) path, finally leaving the message in the outgoing queue.
    'AfterDelivery',
    'Acknowledge',
    'ToOutgoing',
    ]

#---Custom__dlms_1.py---
#I started with MyHandler, Decorate, and CookedHeaders as exemplars, but backtracked to this skeleton

import re

from Mailman import Utils
from Mailman import Errors
from Mailman.i18n import _
from Mailman.Handlers import Hold
from Mailman.Handlers import Moderate
from Mailman.Logging.Syslog import syslog


def process(mlist, msg, msgdata):
    syslog('post','msgdata=%s' % msgdata)

#-----------------------------------------------

Harry G. George
harry.g.george at boeing.com
425-717-7403 


More information about the Mailman-Users mailing list