No subject
Ken Manheimer
klm@python.org
Tue, 28 Apr 1998 14:25:32 -0400 (EDT)
Last thursday i posted a patch that was missing a piece, and would
break things if used alone. It was in response to janne's patch to
get rid of double reply-to's, and involved doing a "del msg[...]"
instead iterating over the message headers. It turns out that the
headers were part of an OutgoingMessage instance, which didn't support
__delitem__. The patch below solves that - sorry about the confusion!
Ken
Index: mm_message.py
===================================================================
RCS file: /hosts/parrot/local/cvsroot/mailman/modules/mm_message.py,v
retrieving revision 1.6
diff -c -r1.6 mm_message.py
*** mm_message.py 1998/04/13 04:59:14 1.6
--- mm_message.py 1998/04/28 18:13:18
***************
*** 1,6 ****
"""Embody incoming and outgoing messages as objects."""
! __version__ = "1.6"
import sys
--- 1,6 ----
"""Embody incoming and outgoing messages as objects."""
! __version__ = "1.7"
import sys
***************
*** 91,97 ****
string.lower(name) + ':'):
self.headers[i] = '%s: %s' % (name, value)
! # XXX Eventually (1.5.1?) Python rfc822.Message() will have it's own
# __delitem__.
def __delitem__(self, name):
"""Delete all occurrences of a specific header, if it is present."""
--- 91,97 ----
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."""
***************
*** 128,140 ****
self.sender = sender
def SetHeaders(self, headers):
! self.headers = map(AddBackNewline, string.split(headers, '\n'))
! def CacheHeaders(header, s=self):
i = string.find(header, ':')
! s.cached_headers[string.lower(string.strip(header[:i]))
! ] = header[i+2:]
! map(CacheHeaders, self.headers)
def SetHeader(self, header, value, crush_duplicates=1):
if value[-1] <> '\n':
--- 128,141 ----
self.sender = sender
def SetHeaders(self, headers):
! self.headers = map(AddBackNewline, string.split(headers, '\n'))
! self.CacheHeaders()
! def CacheHeaders(self):
! for header in self.headers:
i = string.find(header, ':')
! self.cached_headers[string.lower(string.strip(header[:i]))
! ] = header[i+2:]
def SetHeader(self, header, value, crush_duplicates=1):
if value[-1] <> '\n':
***************
*** 178,180 ****
--- 179,196 ----
if not self.cached_headers.has_key(str):
return None
return self.cached_headers[str]
+
+ def __delitem__(self, name):
+ if not self.getheader(name):
+ return None
+ newheaders = []
+ name = string.lower(name)
+ nlen = len(name)
+ for h in self.headers:
+ if (len(h) > (nlen+1)
+ and h[nlen] == ":"
+ and string.lower(h[:nlen]) == name):
+ continue
+ newheaders.append(h)
+ self.headers = newheaders
+ self.CacheHeaders()