fettig.net

Message library improvements

Posted by Abe on Tuesday, May 20, 2003 @ 11:44 pm

I’ve been working on improving Hep’s messaging library, fixing the things that have been bugging me about it. The messaging.Message class in particular has seen a lot of improvements. I’m feeling good about it now.

Basically, messaging.Message is just a thin convenience wrapper on top of email.Message (although it doesn’t inherit from it at the moment). This last set of changes was focused on improving the ability to edit existing Message objects. Up until now Hep has created mutipart/alternative messages, and generated the text and HTML versions of a message at the time of generation. But this has some disadvantages: it wastes disk space, and you lose track of the original message format – was it text, with generated HTML, or HTML, with generated text? Also, it wasn’t possible to inject the RSS link URL into the message body as needed, so I had to put it in there at the time of generation, which was less than ideal since it’s really metadata.

Anyhow, now it’s much nicer to work with. Sample code:


>>> import messaging

>>> m = messaging.Message()

>>> m.title = "Hello World"

>>> m.author = "abe@fettig.net"

>>> m.link = "http://www.fettig.net"

>>> m.setHTML("""

...    <h1>Test Message</h1>

...    This is a message in HTML format.

...    """)

>>> print m.asEmail()

Date: Wed, 21 May 2003 03:23:47 -0000

Subject: Hello World

From: abe@fettig.net

MIME-Version: 1.0

Content-Type: text/html

X-Hep-Link: http://www.fettig.net

        <h1>Test message</h1>

        This is a message in HTML format.

Notice how m.asEmail() gives you a nice simple e-mail message, with a content type of ‘text/html‘.

Now, to get a nice mutipart/alternative version of the message, with a text version for mail clients that

don’t support HTML display, and the link embedded in the message body, all you have to do is:


>>> print m.asEmail(generateMissingParts=1)

Date: Wed, 21 May 2003 03:23:47 -0000

Subject: Hello World

From: abe@fettig.net

X-Hep-Link: http://www.fettig.net

MIME-Version: 1.0

Content-Type: multipart/alternative;

        boundary="===============19186210073222743=="

Message-Id: <md5id:73d197064b90f25bb97b870cd82510d4>

--===============19186210073222743==

Content-Type: text/plain; charset="us-ascii"

MIME-Version: 1.0

Content-Transfer-Encoding: 7bit

Test message

This is a message in HTML format.

http://www.fettig.net

--===============19186210073222743==

Content-Type: text/html; charset="us-ascii"

MIME-Version: 1.0

Content-Transfer-Encoding: 7bit

        <h1>Test message</h1>

        This is a message in HTML format.

        <p><a href="http://www.fettig.net">http://www.fettig.net</a></p>

--===============19186210073222743==--

If you‘re using Hep from CVS, now would be a good time to do a cvs update. If there are bugs in this code I’d like to know about it.

Hep Update, May 7: new configuration pages

Posted by Abe on Wednesday, May 7, 2003 @ 4:42 pm

If you update your copy of Hep from CVS you’ll find that there’s a new and improved web interface for adding, changing, and deleting connections, as well as setting protocol options. But before you jump in there and start changing things, a warning: If you rename a connection, you’ll lose any old messages that were associated with it. Also, searching will become very unstable, because search results may refer to messages that no longer exist, or that have moved. These problems will be fixed in time, but keep in mind that you now have the power to shoot yourself in the foot, and don’t rename or delete connections unless you really have to.

Also, let me come out and say that the current web code is really messy. I am not proud of this, and I’m actively working to make it better. In the meantime, please treat it with the same kind of of respect you would give a hot dog factory: enjoy the result, and don’t worry about what’s going on behind the scenes.

Have I mentioned that there’s a mailing list for Hep CVS commits? Just in case you feel the need to know about changes the instant I make them.

Paul Graham compares hackers to artists

Posted by Abe on Wednesday, May 7, 2003 @ 4:13 pm

Paul Graham: Hackers and Painters (thanks to Ted Leung for the link). A intriguing and funny look at the difference between scientific and artistic professions, the role of the day job, and the importance of empathy in software design. (And it’s an even better read the second time).

Hep Update, May 2: Textile, Lupy, Windows file paths

Posted by Abe on Friday, May 2, 2003 @ 4:48 pm

Is it Friday again already?

I’ve checked in a couple of small (but important) changes to messaging in CVS. First, text-to-html conversion is now done with Mark’s PyTextile module. See the original textile page for more information. Second, I fixed URL parsing to handle windows paths correctly – now Hep should work on Windows even if you have an abolute path for ‘root’ in hep.ini.

Also there’s a new version of Lupy out. You don’t have to upgrade, but you can if you’d like – I’m using it with my personal copy of Hep and it works fine.