diff options
| author | klm | 1998-09-30 17:03:44 +0000 |
|---|---|---|
| committer | klm | 1998-09-30 17:03:44 +0000 |
| commit | 4644b4ba0afaca2436cd0221765635b113fceab5 (patch) | |
| tree | e3bf157bec228a4f1327a2dd55a259c3285f28a7 | |
| parent | 3f806409ad7c379993f87a69f018d687664c436f (diff) | |
| download | mailman-4644b4ba0afaca2436cd0221765635b113fceab5.tar.gz mailman-4644b4ba0afaca2436cd0221765635b113fceab5.tar.zst mailman-4644b4ba0afaca2436cd0221765635b113fceab5.zip | |
.SetHeader(): New headers would not show in resulting message unless
optional "crush_duplicates" was set to 0, because the msg.dict would
get the new entry, but the msg.headers would not. I've changed the
code so that the non-crush_duplicates addition to msg.headers would
happen whenever the header is new, regardless of crush_duplicates
setting. (Of course, the newness of the header means there are no
duplicates to crush...)
Incidentally! John, there's a line at the top of this routine whose
purpose i don't understand - i think it was there when i got the code,
so i'm wondering if you know about it. It's the first line of code in
the routine:
name = "%s%s" % (name[0], name[1:])
The only thing i can think this would serve is to establish that the
length of the name is at least 1 - seems to me it would be more
efficient and clear to make the check explicit, if that's the purpose,
avoid the assignment, etc. I suspect i'm missing something here - can
you shed any light??
| -rw-r--r-- | Mailman/Message.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Mailman/Message.py b/Mailman/Message.py index cc3fe2916..45c355c9d 100644 --- a/Mailman/Message.py +++ b/Mailman/Message.py @@ -121,17 +121,19 @@ class IncomingMessage(rfc822.Message): def SetHeader(self, name, value, crush_duplicates=1): # Well, we crush dups in the dict no matter what... name = "%s%s" % (name[0], name[1:]) + 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: + if not crush_duplicates or newheader: self.headers.append('%s: %s' % (name, value)) return - 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) + 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__. |
