summaryrefslogtreecommitdiff
path: root/Mailman/Message.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* OwnerNotification: New convenience class, derives frombwarsaw2002-10-151-0/+15
| | | | | | | | | UserNotification but provides a different constructor. It calculates the recipients from the list's owners and, if the tomoderators flag is true (the default), includes the list's moderators. The ctor also munges the To header so that it looks like it's being sent to the list's -owner address.
* __setstate__(): This plus email-2.4.3 should fix (most of) Peerbwarsaw2002-10-141-2/+33
| | | | | | | | | | | | | | | | | | Heinlein's recent problems. This patch adds several things to better update pickled Message objects to the latest email package. Specifically, __init__(): Add a version number to Message objects so that we can make __setstate__() more efficient (I don't want to do the next bit of hackery for every single unpickled Message object). __setstate__(): For Message objects older than the current email package version, we'll ensure that the data format is the same. We keep the previous updates and add one that trolls through the message headers, ensuring that if any of the headers are Header instances, that their chunks all have 2nd items as Charset instances, not strings. This is an invariant for email 2.4.3, but older Message instances might not conform.
* get_senders(): Move the list of headers to consult to Defaults.py.inbwarsaw2002-08-061-1/+1
| | | | to aid in debugging.
* __setstate__(): If you had messages in your qfiles directory betweenbwarsaw2002-07-261-1/+11
| | | | | | | | | | | updates from email 2.1 and email 2.2, you're a bit screwed. Message objects grew a _default_type attribute which is *probably* text/plain but that's not guaranteed. Unfortunately at the time __setstate__() is called, we can't know for sure what _default_type ought to be, since it depends on whether this object is contained in a multipart/digest and we have no reference to the container. This is the best we can do.
* UserNotification.send(): If the message doesn't already have abwarsaw2002-05-221-0/+5
| | | | | Precedence: header, add Precedence: bulk since these are typically internally crafted messages destined for a single address.
* get_senders(): Two fixes: first, make sure the unixfrom addition is abwarsaw2002-05-221-4/+4
| | | | | | 2-tuple with an empty realname item; second, we should extract all matching headers with Message.get_all() to make sure we don't miss anything (even though RFC 2822 says those should only appear once).
* send(): Add `reduced_list_headers' so CookHeaders knows not to add thebwarsaw2002-04-081-0/+1
| | | | List-Post: et al headers.
* get_senders(): If there's no envelope, get_unixfrom() will returnbwarsaw2002-04-051-1/+2
| | | | None, which obviously can't be .split(). This is more robust.
* UserNotification.__init__(): If no text argument is given, don't setbwarsaw2002-03-121-4/+2
| | | | | | | | | the character set. The most common reason for this is that the notification message is a multipart/mixed and it makes no sense to give those type of messages a charset. .send(): Set the `nodecorate' key to 1 so that messages that original from the virgin queue don't get headers and footers.
* get_senders(): Application of Jason Mastaler's patch #509386 whichbwarsaw2002-03-071-0/+43
| | | | | | | | | | | | | | | loosens the membership test to check additional headers. I've modified Jason's patch in the following ways: - get_author() -> get_senders() even though I suggested the former. ;) I'd like to eventually deprecate get_sender() so this will be its eventual replacement. - added an optional `headers' argument which defaults to None, meaning the list of headers we agreed on previously. This allows you to pass in the exact headers you want to consult (and their order). - Some implementation details.
* UserNotification.__init__(): If there's no text argument given, butbwarsaw2002-02-281-1/+4
| | | | | | | | | there was a lang argument given, call self.set_charset() instead of doing nothing. Note that when a text argument is given, set_charset() is called implicitly by set_payload(). Otherwise, given lang but no text results in no MIME-Version: header being set.
* __setstate__(): When unpickling Message instances, check to make surebwarsaw2002-02-231-0/+6
| | | | | | | | | | | | | | they have a _charset attribute, adding a default one if not. This should fix a problem I think Dan Mick had, which I believe is caused by a Message object being pickled w/ version 0.96 of the email package, and unpickled by 0.97/1.1 of the email package. Why doesn't this go into email.Message.Message? Because I don't want to clutter its code up with something that should both be transient and assumes that Message is pickled. Mailman seems more responsible for the pickle consistency (if every Python class that grew an attribute had to have such schema migration code, we'd be up sh*ts creek).
* UserNotification.__init__(): Add a `lang' optional argument so thatbwarsaw2002-02-111-3/+10
| | | | | | | charset information can be propagated into the headers, if necessary. Use the new mimelib/email package's Charset and Header classes. Patch by Ben Gertzfield. Requires email 0.97.
* Give Message class an __repr__() since apparently the pretty printerbwarsaw2002-01-171-0/+4
| | | | | module pprint uses repr() instead of str(). This aids in debugging with bin/dumpdb.
* send(): RFC 2822 requires the Date: header, and not all MTAs insertbwarsaw2002-01-111-1/+4
| | | | | | | one if it's missing (most notably qmail). It's easy and correct for us to add a compliant one. SF patch #500670 by Jason Mastaler.
* get_sender(): Minor efficiency.bwarsaw2001-10-151-1/+1
|
* Convert from mimelib to email.bwarsaw2001-10-011-6/+4
| | | | | Also, use cStringIO directly instead of our own hack-around StringIO module.
* get_sender(): Watch out for missing Sender: or From: fields, whichbwarsaw2001-07-061-4/+15
| | | | | | | | | | | cause None to be returned from self.__getitem__(). Keep looking through headers if that happens (this avoids a bug reported by Mentor Cana on messages with no Sender: header and USE_ENVELOPE_SENDER set to true). send(): If the message doesn't have a Message-ID (and it probably won't), craft one. This aids in debugging because the message-id will get logged to logs/smtp.
* UserNotification.__init__(): change the signature so that the textbwarsaw2001-06-281-2/+3
| | | | | argument defaults to None. Only set the payload when the text argument is not None.
* UserNotification.send(): Add optional **_kws which are passed straightbwarsaw2001-05-251-3/+4
| | | | through to the enqueue() method.
* UserNotification.__init__(): Use the blessed way of doing typebwarsaw2001-05-221-1/+1
| | | | comparisons.
* mimelib's ReprMixin class and module was renamed to StringableMixin inbwarsaw2001-05-011-3/+3
| | | | | the 0.3 release. This means you must download and install the 0.3 version of mimelib to work with the current CVS snapshot!
* De-string-module-ify, transform to using mimelib instead of rfc822,bwarsaw2001-02-151-157/+51
| | | | | | | | | | | | | | | | | | | and use the switchboard interface. Specifically, Message class now multiply derives from mimelib.Message.Message and mimelib.ReprMixin.ReprMixin (for __str__() and get_text()). Other method changes: GetSender() -> get_sender() __init__(), __repr__(), __str__(), Enqueue(), Requeue(): removed OutgoingMessage class removed UserNotification class now inherits from Message and adds: send(): A convenience method for taking an internally crafted message and queuing it to the qfiles/virgin queue.
* Enqueue(): Allow for queuing to alternative queue directories. Ifbwarsaw2000-12-201-8/+20
| | | | | | | | | | | | | | | | | newdata or kws has an item called "_whichq", this specifies the directory to queue to, defaulting to INQUEUE_DIR. The metadata "filebase" is always set to __filebase, not just when the metadata is created for the first time. When writing the .db file (i.e. containing the metadata), always write it after the .msg text file, and always write it to a temporary file, with an os.rename() shuffle. This should avoid race conditions when queuing a message to another queue because the queue runners only key off of files ending in ".db". Requeue(): New method which calls Enqueue() after zapping self.__filebase so it'll be recalculated.
* OutgoingMessage.__init__(): Reversing patch 1.35 since this breaks thebwarsaw2000-08-021-12/+4
| | | | | contract with rfc822.Message.__init__() and also breaks news->mail gatewaying. A different patch will be applied to fix SF bug #109220.
* Enqueue(): Watch for the _dirty flag in the msgdata dictionary. Thisbwarsaw2000-07-271-3/+6
| | | | | | forces a write of the message text back to disk, even if it already exists. This is used when the message has been changed (e.g. new or changed header, etc.).
* One more try...bwarsaw2000-07-261-5/+8
| | | | | | | | | | | Enqueue(): Only calculate a new filebase (SHA hash) if the object wasn't assigned one in its constructor. Go back to including the current float time in the hash input. Message.__init__(): Take an optional `filebase' argument which can be restored from an enqueued message. This guarantees that a message, once assigned a hash value for its filebase, continues to use that filebase for its entire life.
* Enqueue(): Oops, you can't include the current time since the hashingbwarsaw2000-07-261-1/+1
| | | | algorithm needs to be reproducible.
* Enqueue(): Elaborate on the text fed to the SHA hashing function forbwarsaw2000-07-261-2/+4
| | | | | | | | | | | | calculating the file name. If a message is sent to two lists simultaneously and the receiving MTA doesn't distinguish them with something like a Delivered-To: header (as Postfix does), the hashes could be the same, prevent one or the other list from receiving the message. Now the hash is composed of the message's text, the destination list's name, and a string representation of the current floating point time. That ought to be unique enough for every message.
* OutgoingMessage.__init__(): Avoid the messy semantics ofbwarsaw2000-07-251-4/+12
| | | | | | rfc822.Message when the first line contains a colon. A blank header-terminating line is prepended to the given text if the first line contains a colon.
* UserNotification.__init__(): If recip is a list, then string join thebwarsaw2000-07-241-3/+7
| | | | | elements for the value of the To: field, and assign a copy of the list to self.recips. Otherwise do the old behavior.
* Enqueue(): New convention; msgdata keys that start with leadingbwarsaw2000-06-201-0/+5
| | | | underscore are volatile and don't get saved to disk.
* GetSender(): Return '' as the fallback false return value instead ofbwarsaw2000-06-141-1/+1
| | | | None. The type of the return value must always be a string.
* In a bit of a kludge, added an __repr__() which returns a stringbwarsaw2000-05-311-2/+11
| | | | | | | | | | | | | | | | | composed of - the unixfrom (i.e. From_ ) line - the rfc822 headers - a blank line - the body of the message This can be used to completely reconstruct the message as received by the MTA (and as needed by Pipermail). The __str__() still returns just the rfc822 headers and the body of the message. Enqueue(): Put the repr() in the .msg file, so that it can be completely reproduced.
* Message.__str__(): Include the unixfrom line in the return value; thisbwarsaw2000-05-311-2/+1
| | | | | | should fix problems where approved held messages weren't being archived properly, and other problems. Thanks to Thomas Wouters for tracking this problem.
* Enqueue(): New method to handle all the details of enqueuing a messagebwarsaw2000-05-081-3/+63
| | | | | | | | for re-delivery by qrunner. This makes it very easy for other clients to make sure a message doesn't get lost. The interface to this method is a bit convoluted, but is convenient for different calling conventions. See the docstring for details.
* Update the copyright lines to include the years 1999 & 2000.bwarsaw2000-03-211-1/+1
|
* GetSender(): Every access of the "sender" (really author) should nowbwarsaw2000-03-031-32/+47
| | | | | | | | | go through this one method. This consolidates and makes consistent the use of the From:, Sender:, and envelope-sender headers, and the search order based on USE_ENVELOPE_SENDER. The docstring explains the semantics of this method. GetEnvelopeSender(): Removed.
* GetSenderName(): Removed.bwarsaw1999-12-161-7/+1
|
* OutgoingMessage.__init__(): take an optional text argument, and passbwarsaw1999-11-241-2/+17
| | | | | | | | | that to the StringIO constructor. Useful for subclassing. UserNotification: Very useful subclass of OutgoingMessage which takes a recipient, a sender, a subject, and the message text, and sets the appropriate headers and `recips' attribute for use in the message pipeline.
* Greatly simplified by basing all this on the up-to-date rfc822.Messagebwarsaw1999-11-101-200/+33
| | | | | | | | | | | | | | object, which supports a writeable interface. Lots of cruft can go. Message.Message: Some of the API methods from previous incarnations are kept for convenience, notably: GetSender(), GetEnvelopeSender(), GetSenderTame. Message.__str__(): Flatten the message by concatenating its headers, adding a newline, and the message's body. OutgoingMessage(): convenience class for creating a Message object out of thin air.
* OutgoingMessage.SetDate(): removebwarsaw1999-07-211-3/+0
| | | | | | Utils.DeliverToUser(): Don't add a Date: header even if one is missing in the message. The MTA will always insert an RFC822 compliant header (and we weren't compliant anyway).
* IncomingMessage.GetSender(): Don't assume addresses taken from headershmeland1999-07-011-4/+8
| | | | are valid.
* Changed import of rfc822 to always get the version we distribute withhmeland1999-05-221-47/+8
| | | | | | | | | Mailman. IncomingMessage.SetHeader(): This messed up when changing headers that spanned multiple lines -- changed it to use rfc822.Message's emulation of a mapping type, which seems to get this right. IncomingMessage.__delitem__(): Removed, inherit from rfc822.Message instead.
* minor code formattingbwarsaw1999-03-091-2/+2
|
* More import games. Make sure we get an rfc822.Message with our newbwarsaw1999-01-121-1/+10
| | | | getallrecipients() method.
* Added some XXX comments for later:bwarsaw1998-12-101-0/+2
| | | | | | | | 1) OutgoingMessage.__delitem__() when name is missing probably ought to raise an exception instead of returning None. 2) There probably ought to be at least also an OutgoingMessage.__setitem__() too.
* .SetHeader(): Removed dubious line "name = "%s%s" % (name[0], name[1:])"klm1998-10-061-1/+3
| | | | | and added note about change to distributed rfc822.py as of 1.5.2 - but we'll want to wait a good while before we switch over to that...
* Added DeliverToOwner to Deliverer class in Deliverer.py that passescotton1998-10-011-0/+25
| | | | | | | | | | a message to the -admin address to the owners untouched and with the sender of the original message Added a GetEnvelopeSender method to Message.py that attempts to find the envelope sender from a messages's unix from line for use by DeliverToOwner changed the mailowner script to use DeliverToOwner method instead of the DeliverToList method scott
* .SetHeader(): New headers would not show in resulting message unlessklm1998-09-301-5/+7
| | | | | | | | | | | | | | | | | | | | | | 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??