Nov

29

Your comments are appreciated

I was gearing up to lay down some TDD on a simple comment e-mailing tool. Then, as I was flipping open the Django source to check something, I noticed a "feeds" module in the comments app. I aspire to Larry Wall's [three cardinal virtues of the programmer] (http://www.hhhh.org/wiml/virtues.html) and a news feed of comments sounds at least as useful as a comment e-mailer, and it had the virtue of already existing, right there in Django.

Ah, but then I noticed: What comments gives you is an RSS news feed. Ahem. I'm cultivating a refined sense of snobbery and hating on MySQL is only the beginning. It has to be Atom or nothing. Don't worry; this time I kept things pretty DRY:

class LatestCommentsAtomFeed(LatestCommentFeed):
def subtitle(self):
return self.description()
 
feed_type = Atom1Feed
 
def item_author_name(self, item):
return item.name

All I did was set the feed type and make the subtitle field stand in for the description field. And hey, I figured since we have a name field in the comment, we may as well use it as the author name for each item. I expect there's some obvious reason why I wouldn't want to do this, but in my minimal, unscientific testing with Net News Wire, it seems to work fine.

I don't know where to embed a link to something of as questionable interest as a comments-only news feed. Well, maybe I do. Here you go.