Software Update

Back when I first launched this site (about a year ago now), I mentioned that I’d someday release the blog application I’d written to power it. So far I’ve been held up by two large problems:

  1. The application itself was written using an SVN checkout of Django from April of last year, back when the codebase that became the Django 0.95 release was still known as “the magic-removal branch”.
  2. Some features (notably, a couple things I’ve done with comments) relied on hacking the source of Django itself.

So I’ve been on a mission to clean up the code and get it to a point where I wouldn’t be embarrassed to release it; along the way I’ve been purging features that I don’t actually use, and adding new ones based on features added to Django and useful third-party applications released by the community.

These days, there are two major things holding me up:

  1. I have very little free time, and I don’t always spend that time in front of a computer.
  2. Whenever I write some new feature for the blog application, I end up thinking, “hey, I could make this a bit more generic and spin it off into its own application”.

Today marks the initial release of another little application that got spun off from the blog software: a generic contact-form system that started out simple and then grew a bit (“a bit” — I’m being somewhat facetious here) as I worked to make it more reusable outside of the blog context it was originally designed for.

Full documentation is online and included in the downloadable package, but here’s the short and sweet overview:

  • A base ContactForm class (built with newforms) which handles the simplest case of collecting a name, email address and message, and sending them to your site staff.
  • Various indirections and useful hooks in ContactForm to make it easy to add new functionality by subclassing it and overriding only the bits you need to change (credit for the good parts of its API go to Jacob, credit for any bad parts probably go to me).
  • An example subclass which uses Akismet to performa a spam check on the form (I’ve got an old site which had a contact form and no spam protection; I still get a couple dozen spam submissions from it each month).
  • A view which can handle the mechanics of displaying, validating and sending email from ContactForm or a subclass, and which accepts various parameters to control its behavior.

This one’s definitely still “under development”, and there are probably bugs in it, but I wanted to get it out in the wild to help shake them out; bug reports are welcome (please use the Google Code issue tracker rather than posting bug reports in comments here).

Other code

In the meantime, I’ve also been hacking a bit on two other applications: the user-registration app now has a distutils-enabled package you can download, as well as full documentation, and I’m working on adding a few more features to it (be wary of doing an SVN checkout — there be dragons in the code right now), and template_utils has gone through a few bugfixes and enhancements and is now officially on its third release.

Coming soon

I’ve also got one more app planned before I can go back to finishing up blogging once and for all, but I’ve already got most of it fleshed out; I’ve also recently come into possession of a shiny new Joyent Accelerator, and in honor of that I’ll migrate this site over to it as soon as the new codebase (and a minor redesign) are done.

Once that’s all out the door, I’ve got a couple ideas for my next personal project, and so far none of them involve spinning off a bunch of different applications first, so hopefully they’ll take a little less time. The snippets site is also due for some love, I think, so I’ll be going through the issue tracker, looking for bugs and feature requests to deal with. If you’ve got ideas, be sure to submit them :)

One more thing…

While I’m on the subject of useful third-party apps, I should mention that World Online’s own Christian Metts, a gentleman, scholar, designer and no slouch when it comes to writing nifty code, has released typogrify, a set of incredibly handy template filters for those of us who like to have our typography be as beautiful as our code. You should check it out :)

Comments

David, biologeek
May 28, 2007
#

Two ideas:

  • about registration, it could be useful to add a bit of i18n ;
  • about DjangoSnippets, a search field is missing and navigation by tag need some kind of pagination (looking for a tag 20 by 20 is… hum, you know :-)).

Anyway, thanks for sharing your code!

James Bennett
May 28, 2007
#

Not trying to be mean here, but please report stuff to the issue trackers for the actual projects they concern and not here in comments on blog entries; it’s much, much easier to keep track of stuff that way, and has the advantage of letting you look first to see if someone else has reported the same thing.

Christian Metts
May 28, 2007
#

Darn you. Now I’m going to have to make Typogrify presentable. I so totally had better things to do today. :)

John Heasly
June 17, 2007
#

Hey James,

In a somewhat (I think) related matter, I was able to mash-up your Hacking FreeComment Django tip (http://www.b-list.org/weblog/2006/07/16/django-tips-hacking-freecomment) with what-I-take-to-your “Unobtrusive comment moderation” Django snippet (http://www.djangosnippets.org/snippets/112/).

Specifically, I was able to add the e-mail-sent-when-comment-made goodness of the FreeComment hack entry using the signals methodology demonstrated in the “Unobstrusive” Django snippet.

All it takes is dropping in the three lines of “Hacking FreeComment” code: mail_subject = ‘New comment posted on %s “%s”’ % (self.site.name, self.get_content_object().title) mail_body = ‘On %s, %s posted the following comment on “%s”:nn%s’ % (self.submit_date.strftime(“%A, %B %d, %Y at %I:%M %p”), self.person_name, self.get_content_object().title, self.comment) mail_managers(mail_subject, mail_body, fail_silently=True)

into your “Unbostrusive” snippet. I put ‘em between lines 28 & 29 ‘cause I want to know every time an e-mails sent, regardless of whether it’s spam or too old or whatever. (But I can change this later by moving the lines in the snipped logic!)

A couple of things to watch out for is substituting “instance” for “self” in the three “Hacking FreeComment” lines. And making sure your model has a “title” (or changing the code to match whatever your model does have).

Oh, and adding the from django.core.mail import mail_managers to whichever file you drop the Django snippet into. I decided on the relevant project’s urls.py. Is that the best place?

So, the bottom line is you can have your hack and eat it too (so to speak)!

Thanks for both entries!

Add a comment

You may use Markdown syntax in your comment, but raw HTML will be removed. By posting a comment here, you are agreeing to the terms of my comment policy.