From 7923b90f0349f9e2dc891082e2e1c3bf23b4d79c Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 10 Dec 2007 23:00:14 -0500 Subject: Add .get() to our Message subclass, which ensures that returned values are unicodes if they come from the base class as a string. Get rid of the 'global id'. Now use just Message-ID. Rename X-List-ID-Hash to X-Message-ID-Hash. Do not take Date header into account when calculating this hash. Because of the above change, the assumption is that there will be no Message-ID collisions. Therefore, get rid of IMessageStore .get_message(), .get_messages_by_message_id() and .get_messages_by_hash(). Instead, it's now .get_message_by_id() and .get_message_by_hash() both of which return the message object or None. Message.hash -> Message.message_id_hash When storing a message in the message store, the final path component has the entire hash, not just the leftover parts after directory prefix splitting. MessageStore.delete_message() deletes the file too. Doctests clean up message store messages though the message store instead of directly off the filesystem. --- Mailman/docs/requests.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Mailman/docs/requests.txt') diff --git a/Mailman/docs/requests.txt b/Mailman/docs/requests.txt index 7a395ce94..ea4dcc75d 100644 --- a/Mailman/docs/requests.txt +++ b/Mailman/docs/requests.txt @@ -231,6 +231,9 @@ this case, we won't include any additional metadata. We can also hold a message with some additional metadata. + # Delete the Message-ID from the previous hold so we don't try to store + # collisions in the message storage. + >>> del msg['message-id'] >>> msgdata = dict(sender='aperson@example.com', ... approved=True, ... received_time=123.45) @@ -308,8 +311,7 @@ indicates that the message has been approved. To: alist@example.com Subject: Something important Message-ID: ... - X-List-ID-Hash: ... - X-List-Sequence-Number: ... + X-Message-ID-Hash: ... X-Mailman-Approved-At: ... Here's something important about our mailing list. @@ -338,26 +340,21 @@ is deleted. ... """) >>> id_4 = moderator.hold_message(mlist, msg, {}, 'Needs approval') >>> moderator.handle_message(mlist, id_4, Action.discard) - >>> msgs = config.db.message_store.get_messages_by_message_id(u'<12345>') - >>> list(msgs) - [] + >>> print config.db.message_store.get_message_by_id(u'<12345>') + None But if we ask to preserve the message when we discard it, it will be held in the message store after disposition. >>> id_4 = moderator.hold_message(mlist, msg, {}, 'Needs approval') >>> moderator.handle_message(mlist, id_4, Action.discard, preserve=True) - >>> msgs = config.db.message_store.get_messages_by_message_id(u'<12345>') - >>> msgs = list(msgs) - >>> len(msgs) - 1 - >>> print msgs[0].as_string() + >>> stored_msg = config.db.message_store.get_message_by_id(u'<12345>') + >>> print stored_msg.as_string() From: aperson@example.org To: alist@example.com Subject: Something important Message-ID: <12345> - X-List-ID-Hash: 4CF7EAU3SIXBPXBB5S6PEUMO62MWGQN6 - X-List-Sequence-Number: 1 + X-Message-ID-Hash: 4CF7EAU3SIXBPXBB5S6PEUMO62MWGQN6 Here's something important about our mailing list. @@ -366,6 +363,10 @@ Orthogonal to preservation, the message can also be forwarded to another address. This is helpful for getting the message into the inbox of one of the moderators. + # Set a new Message-ID from the previous hold so we don't try to store + # collisions in the message storage. + >>> del msg['message-id'] + >>> msg['Message-ID'] = u'' >>> id_4 = moderator.hold_message(mlist, msg, {}, 'Needs approval') >>> moderator.handle_message(mlist, id_4, Action.discard, ... forward=[u'zperson@example.com']) @@ -383,9 +384,8 @@ moderators. From: aperson@example.org To: alist@example.com Subject: Something important - Message-ID: <12345> - X-List-ID-Hash: 4CF7EAU3SIXBPXBB5S6PEUMO62MWGQN6 - X-List-Sequence-Number: ... + Message-ID: + X-Message-ID-Hash: EN2R5UQFMOUTCL44FLNNPLSXBIZW62ER Here's something important about our mailing list. -- cgit v1.2.3-70-g09d2