summaryrefslogtreecommitdiff
path: root/Mailman/Message.py
diff options
context:
space:
mode:
authorhmeland1999-05-22 06:05:48 +0000
committerhmeland1999-05-22 06:05:48 +0000
commitff4e4557e2ca2d17308c404de75adf9bdbf3d42f (patch)
tree023e09037a9fcf3f20206f152445c810e1216f18 /Mailman/Message.py
parent0d9535baa0a0d428b1d82d910b640a40240b8b4a (diff)
downloadmailman-ff4e4557e2ca2d17308c404de75adf9bdbf3d42f.tar.gz
mailman-ff4e4557e2ca2d17308c404de75adf9bdbf3d42f.tar.zst
mailman-ff4e4557e2ca2d17308c404de75adf9bdbf3d42f.zip
Diffstat (limited to 'Mailman/Message.py')
-rw-r--r--Mailman/Message.py55
1 files changed, 8 insertions, 47 deletions
diff --git a/Mailman/Message.py b/Mailman/Message.py
index 066e51e27..56dd2ec64 100644
--- a/Mailman/Message.py
+++ b/Mailman/Message.py
@@ -22,13 +22,10 @@ import sys
import string
import time
-# get our hacked copy of Python 1.5.2's rfc822.py
-import rfc822
-try:
- rfc822.Message.getallrecipients
-except AttributeError:
- # the standard module doesn't have our enhancement
- from Mailman.pythonlib import rfc822
+# Python 1.5's version of rfc822.py is buggy and lacks features we
+# depend on -- so we always use the up-to-date version distributed
+# with Mailman.
+from Mailman.pythonlib import rfc822
# Utility functions 2 of these classes use:
@@ -153,47 +150,11 @@ class IncomingMessage(rfc822.Message):
return real_name
def SetHeader(self, name, value, crush_duplicates=1):
- # Well, we crush dups in the dict no matter what...
- # XXX Note that as of Python 1.5.2, rfc822 message objects support
- # a .__setattr__() that does what we want, so eventually we'll
- # want to switch to that instead of mucking w/the internal rep.
- newheader = not self.dict.has_key(string.lower(name))
- self.dict[string.lower(name)] = value
- if value[-1] <> '\n':
- value = value + '\n'
-
- if not crush_duplicates or newheader:
- self.headers.append('%s: %s' % (name, value))
- return
+ if crush_duplicates:
+ self[name] = value
else:
- for i in range(len(self.headers)):
- if (string.lower(self.headers[i][:len(name)+1]) ==
- string.lower(name) + ':'):
- self.headers[i] = '%s: %s' % (name, value)
-
- # XXX Eventually (1.5.1?) Python rfc822.Message() will have its own
- # __delitem__.
- def __delitem__(self, name):
- """Delete all occurrences of a specific header, if it is present."""
- name = string.lower(name)
- if not self.dict.has_key(name):
- return
- del self.dict[name]
- name = name + ':'
- n = len(name)
- list = []
- hit = 0
- for i in range(len(self.headers)):
- line = self.headers[i]
- if string.lower(line[:n]) == name:
- hit = 1
- elif line[:1] not in string.whitespace:
- hit = 0
- if hit:
- list.append(i)
- list.reverse()
- for i in list:
- del self.headers[i]
+ # Only bother with the dict
+ self.dict[string.lower(name)] = value
# This is a simplistic class. It could do multi-line headers etc...
# But it doesn't because I don't need that for this app.