Pre-Thanksgiving Relaunch Update
Progress on my personal site relaunch for Sitesprint II continues apace. At this point all the work has been on the backend code but my gains there have been good. In my last post I set some ground rules which I have so far kept, including five significant commits to my code repository per week. Admittedly, it’s only been one week, but whatever... The result is Belleville, a blogging CMS written in Django. As I mentioned, this site currently runs in a Django-based CMS I wrote a while ago. Does the world really need yet another django-based blogging CMS? Or another blogging CMS at all? Well, no, probably not; but I do. And my hope is that this one represents a good example of code that is idiomatic to Django, is extensible, offers a nice feature set, and is easy to theme; in other words, I hope other folks might find it useful too. It’s open source and free for the taking.
Today I used a nifty little package called StatSVN to take a look at my work—via my subversion repository—thus far and the results are encouraging.
I announced this on Sunday, November 15. Since then, the size of the project has grown from 1,200 lines of code to 1750 lines, an increase of 550 lines. (The initial lines of code number is also misleadingly high: a lot of that includes the auto-generated sphinx scaffolding. The real number is probably closer to 400 - 500 lines.) Are lines of a code a good measure of anything? Well, no, but at least I know I’ve been working! If you’re interested, take a look at the full set of stats about the project repository to date.
It’s probably worthwhile to pause for a moment and survey where the project stands. Here are the various components:
Author Application
This is a pretty simple application which allows a Belleville user to create multiple author profiles (that’s right, you can use this for a multi-author blog). Profiles include name, bio and picture. If you know Django, you’d expect that this app would extend django.contrib.users, and you’d be right. The application is done, and includes some very primitive templates to provide a list of authors and detail pages. The app also includes a relatively complete compliment of unit tests.
Site Preferences
This app solves a problem I’ve had for a while: how to set site preferences through the Django admin, rather than in settings.py. Obviously, certain settings belong in settings.py, things having to do with the environment in which the project is running, low-level configuration directives, etc...but I’ve often wished that some settings specific to a django project could be set through Django’s admin interface, which will also be the admin interface for Belleville. One issue is the need for a “Singleton” pattern in the Django admin. The use of that word in this context is probably an abuse of terminology worthy of a sternly-worded letter from the gang of four, but it’s not totally inapt: obviously there should only be one settings object allowed for a site, but how to accomplish that? My answer is pretty simple: I use django’s sites framework and extend the django.contib.sites.models.Site to include other configuration options. The result, is, I think pretty satisfactory. A preference object in my Site Preferences app (which is just a django record like any other) has a one-to-one relationship with a site:

As you can see, mazelife.com can only have one preference object associated with it at a time. The Site Preferences app has some nice features, including a context processor which inserts this data into all template contexts (thus giving you useful data in templates like site, blog and tumblelog title), and a caching mechanism (much like Django’s Site.objects.get_current) to avoid having an additional DB lookup on every request. This app is done, but I haven’t written any tests for it yet.
Blogging
Obviously the most important piece of Belleville, it’s also the least complete. Data models for blog and tumblelog posts exist, with some managers to provide a little sugar. Most views are done, but no templates are yet. I also plan to have the tumblelog entry interface offer the ability to cross-post to twitter, but that piece has not been started. The admin will require a little hacking to provide a character count for tumblelog entries, but I don’t anticipate that will be a problem as it’s all done in javascript.
Third-Party Modules/Dependencies
Tagging
I plan to use django-tagging as it seems to be a best-of-breed pluggable Django app. Blog and tumblelog entries will be taggable.
Site Search
I plan to use my own site_search app for this, and I don’t anticipate any problems wiring it into belleville.
Rich Text Editing
For rich text editing in the Django admin interface (a feature my blog sorely lacks) I’ll probably use django-tinymce: I’ve used it before and it’s great.
Miscellaneous
There are a couple of nifty things in here which don’t rise to the level of apps, but are still cool. One is a context processor which provides navigation breadcrumbs automagically and some glue to make it possible (I knew python’s function annotations were useful for something). Also included is a utility to provide a consistent interface for pagination.
That’s backend. Frontend work will begin (hopefully) this weekend.

Leave a comment:
Comments are closed for this entry.