Archive

Posts Tagged ‘duplicate’

Mailman: Preventing Duplicate Archiving and Multiple Subject Prefixes with Umbrella Lists

August 30th, 2009 3 comments

This defines the process of deleting any existing X-No-Archive and X-No-Subject-Prefix headers to prevent duplication, followed by the addition of an X-No-Archive: Yes header and an X-No-Subject-Prefix: Yes header.

~mailman/Mailman/Handlers/Umbrella.py:

def process(mlist, msg, msgdata):
    del msg['x-no-archive']
    msg['X-No-Archive'] = 'Yes'
    del msg['x-no-subject-prefix']
    msg['X-No-Subject-Prefix'] = 'Yes'

The following then inserts that handler into the message pipeline after archiving so that when a message is archived once (in the first list it hits) it is marked not to be archived again in any subsequent lists it is sent to.

~mailman/Mailman/mm_cfg.py:

GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('AfterDelivery'), 'Umbrella')

Mailman doesn’t archive messages containing an X-No-Archive header, however it doesn’t know about the X-No-Subject-Prefix header, so we have to tell it in ~mailman/Mailman/Handlers/CookHeaders.py:

Patch

*** CookHeaders.py.old  2007-09-21 10:33:33.000000000 +0100
--- CookHeaders.py      2007-09-21 10:10:38.000000000 +0100
***************
*** 217,224 ****
--- 217,226 ----
  def prefix_subject(mlist, msg, msgdata):
      # Add the subject prefix unless the message is a digest or is being fast
      # tracked (e.g. internally crafted, delivered to a single user such as the
      # list admin).
+     if msg.has_key('x-no-subject-prefix') and msg.get('x-no-subject-prefix', '').lower() == 'yes':
+         return
      prefix = mlist.subject_prefix
      subject = msg.get('subject', '')
      # Try to figure out what the continuation_ws is for the header
      if isinstance(subject, Header):
Categories: Mailman Tags: , ,