| Joel Uckelman on Fri, 10 Dec 2004 15:51:30 -0600 (CST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [nimh-dev] Message problem |
Thus spake Joel Uckelman: > I've encountered a problem with Message that I don't know how to solve. > What I'd written for the nimh.Message class wasn't actually being called, > due to there being no openessage() method in nimh.Folder. Once I added > that, I found that I can't properly construct a nimh.Message. > > Here's the problem: nimh.Message is a subclass of email.Message. There are > only three ways to create an email.Message, by using email.message_from_file( > ), > by using email.Parser, or by using email.Message's ctor directly. > > email.message_from_file() just calls email.Parser, so effectively those two > are the same. email.Parser returns an email.Message, not an nimh.Message, so > I don't see how that could be used to get a nimh.Message. The ctor for > email.Message takes no arguments---it creates an empty message---and none of > the member functions will read in a file. So I don't see how one could ever > usefully subclass email.Message without completely rewriting email.Parser > to return the subclass. > > I don't get it. I'm going to commit what I have right now so you guys can > see it. Follow-up: I figured it out. email.message_from_file() can take a class name as a second argument. That way, you can tell it to make a Foo instead of an email.Message. Also, I renamed the nimh library classes to more closely follow the naming conventions in mhlib: nimh_nimh -> MH nimh_folder -> Folder nimh_message -> Message There should be no need to import mhlib outside of these three classes. _______________________________________________ nimh-dev mailing list nimh-dev@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/nimh-dev