------------------------------------------------------------
revno: 6700
committer: Barry Warsaw <[email protected]>
branch nick: hacking
timestamp: Tue 2009-03-03 10:15:42 -0500
message:
  There are some situations where the RFC 2919 List-ID header must be explicitly
  set.  Make this possible by moving list_id to an attribute of the MailingList
  object instead of hard-coding its calculation in cook_headers.py.
modified:
  src/mailman/database/mailinglist.py
  src/mailman/database/mailman.sql
  src/mailman/interfaces/mailinglist.py
  src/mailman/pipeline/cook_headers.py
  src/mailman/pipeline/docs/cook-headers.txt
  src/mailman/styles/default.py

=== modified file 'src/mailman/database/mailinglist.py'
--- src/mailman/database/mailinglist.py 2009-03-03 05:31:03 +0000
+++ src/mailman/database/mailinglist.py 2009-03-03 15:15:42 +0000
@@ -61,6 +61,9 @@
     # List identity
     list_name = Unicode()
     host_name = Unicode()
+    list_id = Unicode()
+    include_list_post_header = Bool()
+    include_rfc2369_headers = Bool()
     # Attributes not directly modifiable via the web u/i
     created_at = DateTime()
     admin_member_chunksize = Int()
@@ -130,8 +133,6 @@
     goodbye_msg = Unicode()
     header_matches = Pickle()
     hold_these_nonmembers = Pickle()
-    include_list_post_header = Bool()
-    include_rfc2369_headers = Bool()
     info = Unicode()
     linked_newsgroup = Unicode()
     max_days_to_hold = Int()

=== modified file 'src/mailman/database/mailman.sql'
--- src/mailman/database/mailman.sql    2009-03-03 05:31:03 +0000
+++ src/mailman/database/mailman.sql    2009-03-03 15:15:42 +0000
@@ -74,8 +74,13 @@
 );
 CREATE TABLE mailinglist (
         id INTEGER NOT NULL,
+        -- List identity
         list_name TEXT,
         host_name TEXT,
+        list_id TEXT,
+        include_list_post_header BOOLEAN,
+        include_rfc2369_headers BOOLEAN,
+        -- Attributes not directly modifiable via the web u/i        
         created_at TIMESTAMP,
         admin_member_chunksize INTEGER,
         next_request_id INTEGER,
@@ -136,8 +141,6 @@
         goodbye_msg TEXT,
         header_matches BLOB,
         hold_these_nonmembers BLOB,
-        include_list_post_header BOOLEAN,
-        include_rfc2369_headers BOOLEAN,
         info TEXT,
         linked_newsgroup TEXT,
         max_days_to_hold INTEGER,

=== modified file 'src/mailman/interfaces/mailinglist.py'
--- src/mailman/interfaces/mailinglist.py       2009-03-03 05:31:03 +0000
+++ src/mailman/interfaces/mailinglist.py       2009-03-03 15:15:42 +0000
@@ -66,6 +66,8 @@
 class IMailingList(Interface):
     """A mailing list."""
 
+    # List identity
+
     list_name = Attribute(
         """The read-only short name of the mailing list.  Note that where a
         Mailman installation supports multiple domains, this short name may
@@ -75,13 +77,6 @@
         posted to [email protected], then the list_name is 'mylist'.
         """)
 
-    real_name = Attribute(
-        """The short human-readable descriptive name for the mailing list.  By
-        default, this is the capitalized `list_name`, but it can be changed to
-        anything.  This is used in locations such as the message footers and
-        Subject prefix.
-        """)
-
     host_name = Attribute(
         """The read-only domain name 'hosting' this mailing list.  This is
         always the domain name part of the posting email address, and it may
@@ -97,6 +92,26 @@
         always comprised of the list_name + '@' + host_name.
         """)
 
+    real_name = Attribute(
+        """The short human-readable descriptive name for the mailing list.  By
+        default, this is the capitalized `list_name`, but it can be changed to
+        anything.  This is used in locations such as the message footers and
+        Subject prefix.
+        """)
+
+    list_id = Attribute(
+        """The RFC 2919 List-ID header value.""")
+
+    include_list_post_header = Attribute(
+        """Flag specifying whether to include the RFC 2369 List-Post header.
+        This is usually set to True, except for announce-only lists.""")
+
+    include_rfc2369_headers = Attribute(
+        """Flag specifying whether to include any RFC 2369 header, including
+        the RFC 2919 List-ID header.""")
+
+    # Contact addresses
+
     posting_address = Attribute(
         """The address to which messages are posted for copying to the full
         list membership, where 'full' of course means those members for which

=== modified file 'src/mailman/pipeline/cook_headers.py'
--- src/mailman/pipeline/cook_headers.py        2009-02-13 01:36:21 +0000
+++ src/mailman/pipeline/cook_headers.py        2009-03-03 15:15:42 +0000
@@ -179,17 +179,16 @@
     if msgdata.get('_nolist') or not mlist.include_rfc2369_headers:
         return
     # This will act like an email address for purposes of formataddr()
-    listid = '{0}.{1}'.format(mlist.list_name, mlist.host_name)
     cset = mlist.preferred_language.charset
     if mlist.description:
         # Don't wrap the header since here we just want to get it properly RFC
         # 2047 encoded.
         i18ndesc = uheader(mlist, mlist.description, 'List-Id', maxlinelen=998)
-        listid_h = formataddr((str(i18ndesc), listid))
+        listid_h = formataddr((str(i18ndesc), mlist.list_id))
     else:
         # without desc we need to ensure the MUST brackets
-        listid_h = '<{0}>'.format(listid)
-    # We always add a List-ID: header.
+        listid_h = '<{0}>'.format(mlist.list_id)
+    # No other agent should add a List-ID header except Mailman.
     del msg['list-id']
     msg['List-Id'] = listid_h
     # For internally crafted messages, we also add a (nonstandard),

=== modified file 'src/mailman/pipeline/docs/cook-headers.txt'
--- src/mailman/pipeline/docs/cook-headers.txt  2009-02-10 03:19:18 +0000
+++ src/mailman/pipeline/docs/cook-headers.txt  2009-03-03 15:15:42 +0000
@@ -7,8 +7,7 @@
 changes depend on mailing list settings and others depend on how the message
 is getting sent through the system.  We'll take things one-by-one.
 
-    >>> from mailman.pipeline.cook_headers import process
-    >>> mlist = config.db.list_manager.create(u'[email protected]')
+    >>> mlist = create_list(u'[email protected]')
     >>> mlist.subject_prefix = u''
     >>> mlist.include_list_post_header = False
     >>> mlist.archive = True
@@ -26,6 +25,8 @@
     ... A message of great import.
     ... """)
     >>> msgdata = {}
+
+    >>> from mailman.pipeline.cook_headers import process
     >>> process(mlist, msg, msgdata)
     >>> msgdata['original_sender']
     u'[email protected]'
@@ -219,6 +220,38 @@
        <mailto:[email protected]>
     ---end---
 
+There are some circumstances when the list administrator wants to explicitly
+set the List-ID header.
+
+    >>> from mailman.domain import Domain
+    >>> domain = Domain(u'mail.example.net')
+    >>> config.domains[domain.email_host] = domain
+    >>> mlist.host_name = u'mail.example.net'
+
+    >>> process(mlist, msg, {})
+    >>> print msg['list-id']
+    My test mailing list <_xtest.example.com>
+
+    >>> mlist.list_id = u'_xtest.mail.example.net'
+    >>> process(mlist, msg, {})
+    >>> print msg['list-id']
+    My test mailing list <_xtest.mail.example.net>
+
+    >>> mlist.host_name = u'example.com'
+    >>> mlist.list_id = u'_xtest.example.com'
+
+Any existing List-ID headers are removed from the original message.
+
+    >>> msg = message_from_string("""\
+    ... From: [email protected]
+    ... List-ID: <123.456.789>
+    ...
+    ... """)
+
+    >>> process(mlist, msg, {})
+    >>> sorted(msg.get_all('list-id'))
+    [u'My test mailing list <_xtest.example.com>']
+
 Administrative messages crafted by Mailman will have a reduced set of headers.
 
     >>> msg = message_from_string("""\

=== modified file 'src/mailman/styles/default.py'
--- src/mailman/styles/default.py       2009-03-03 05:31:03 +0000
+++ src/mailman/styles/default.py       2009-03-03 15:15:42 +0000
@@ -52,12 +52,15 @@
         """See `IStyle`."""
         # For cut-n-paste convenience.
         mlist = mailing_list
+        # List identity.
+        mlist.real_name = mlist.list_name.capitalize()
+        mlist.list_id = u'{0.list_name}.{0.host_name}'.format(mlist)
+        mlist.include_rfc2369_headers = True
+        mlist.include_list_post_header = True
         # Most of these were ripped from the old MailList.InitVars() method.
         mlist.volume = 1
         mlist.post_id = 1
         mlist.new_member_options = 256
-        # This stuff is configurable
-        mlist.real_name = mlist.list_name.capitalize()
         mlist.respond_to_post_requests = True
         mlist.advertised = True
         mlist.max_num_recipients = 10
@@ -92,8 +95,6 @@
         mlist.admin_member_chunksize = 30
         mlist.administrivia = True
         mlist.preferred_language = 'en'
-        mlist.include_rfc2369_headers = True
-        mlist.include_list_post_header = True
         mlist.collapse_alternatives = True
         # Digest related variables
         mlist.digestable = True



--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0

Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to