Microsoft just released a Community Technology Preview (CTP) version of Visual Studio 2010. Of particular interest is the inclusion of a subset of the C++0x spec. (update: now with a massive rvalue reference article) As it turns out, it is a very juicy subset!
Django comes with a very flexible built-in framework for handling comments bound to arbitrary model objects, complete with automatic generation and handling of timestamps and a honeypot field designed to stop spambots. However, these measures are often easy to circumvent by spammers, prompting the use of other approaches such as serverside spam filtering services like akismet, requiring a moderator to approve all comments before they are publicly shown, or, more commonly through the use of a captcha.
An increasingly popular captcha solution, both due to its effectiveness and the fact that it is free to use, is reCAPTCHA, which combines combating spam with digitizing old books. Essentially, everybody wins! All you have to do is register for a private/public key pair at their site (used to ensure spammers cannot fake the data), and you're good to go. That is, after you've added support for it in your application, of course (which incidentally is what this is about).
This post gives a hopefully straight forward overview of how I went about adding support for reCAPTCHA to this blog, using Django 1.0 and its contrib.comments framework as a base. I have tried to be as unintrusive as possible, adding no more code (or ugly hacks) than I have deemed necessary.
Update Dec. 10 2008: Rewrote implementation completely, as the old, signal-based one failed to properly handle user feedback for invalid captchas.
After posting the Boost-Centric Factory Pattern Implementation article, I got some excellent feedback and advice on things that could be improved. Turns out that was most of the (non-abstract) factory code! I'm leaving the old implementation on archive in case anyone prefers its way of doing things. This post outlines the bulk of the changes made and the reasoning behind them.
Those of you who have read Andrei Alexandrescu's excellent Modern C++ Design-book should be well familiar with his Loki-library and its Factory/AbstractFactory implementations. Through clever metaprogramming and extensive use of compile-time policies, implementational details are kept hidden and coupling is greatly reduced (partially through auto-generation of class-hierarchies)—which in turn means better and more maintainable code can be effortlessly written by the library's users.
One of the fundamental concepts of Loki is the notion and use of typelists—that is, lists of types (rather than runtime values) that can be processed at compile-time using metaprogramming—a concept that has been greatly enhanced and extended with the Boost Metaprogramming Library (MPL). Since Loki and Boost exist independently, I figured it might be fun to adapt Alexandrescu's factory patterns into something that exploits the functionality already present in Boost, particularly the MPL and Boost.Preprocessor.
Last update: 7th of December, 2009. Updated post for version 1.2.2
At last managed to shake off a delightful run of procrastination and upload my custom little blog software (created with Django and a healthy serving of generic views) to Webfaction, a process that was almost frighteningly straight forward and efficient for someone that is more commonly used to wrangling software with its own ideas of when and where to stab you in the face. Much recommended (Webfaction, not the stabbing part)!
The blog code is still kind of rough around the edges, with parts missing here and there, much like a Lego set left unattended with children. The current lack of comment-functionality (and blog posts, for that matter) also means that those eagerly clenching their fists at the prospect of browsing 200x cheap russian casino spams per second will have to face their first disappointment in years.
As for this site itself, it will be used as more of a personal blog-kind-of-contraption on programming et al, because there really aren't enough opinionated blogs by nerds on the internet as it is.