~brad-allendev/mailman/cleanup

« back to all changes in this revision

Viewing changes to src/mailman/inject.py

  • Committer: Barry Warsaw
  • Date: 2009-02-20 03:23:42 UTC
  • Revision ID: barry@list.org-20090220032342-skiwfi2l4pm380ft
Major cleanup of the automatic response stuff.

inject_message() grows a keyword argument dictionary which gets merged into
the message metadata.

Move NODELTA into the autorespond interface as ALWAYS_REPLY.

Convert the integer response values into the ResponseAction enum.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
 
34
34
 
35
 
def inject_message(mlist, msg, recips=None, switchboard=None):
 
35
def inject_message(mlist, msg, recips=None, switchboard=None, **kws):
36
36
    """Inject a message into a queue.
37
37
 
38
38
    :param mlist: The mailing list this message is destined for.
45
45
    :param switchboard: Optional name of switchboard to inject this message
46
46
        into.  If not given, the 'in' switchboard is used.
47
47
    :type switchboard: string
 
48
    :param kws: Additional values for the message metadata.
 
49
    :type kws: dictionary
48
50
    """
49
51
    if switchboard is None:
50
52
        switchboard = 'in'
55
57
    # Ditto for Date: as required by RFC 2822.
56
58
    if 'date' not in msg:
57
59
        msg['Date'] = formatdate(localtime=True)
58
 
    kws = dict(
 
60
    msgdata = dict(
59
61
        listname=mlist.fqdn_listname,
60
 
        tolist=True,
61
62
        original_size=getattr(msg, 'original_size', len(msg.as_string())),
62
63
        )
 
64
    msgdata.update(kws)
63
65
    if recips is not None:
64
 
        kws['recips'] = recips
65
 
    config.switchboards[switchboard].enqueue(msg, **kws)
 
66
        msgdata['recips'] = recips
 
67
    config.switchboards[switchboard].enqueue(msg, **msgdata)
66
68
 
67
69
 
68
70