Blog

Weblog Project

Mar 18, 2007 — Whitney Young

As announced at the end of last month, we took it upon ourselves to create a weblog application. The main point was to replace Typo and reduce the large overhead the weblog was creating on the server. We wanted a fully functional weblog, but didn't need all the bells and whistles from Typo. It's pretty much finished now, and it was a lot of fun to work on.

Here are some of the features:

  • Spam filtering (with Akismet)
  • Easy caching (integrated with Django's caching mechanisms)
  • Article tagging
  • Article archives
  • Multiple user support
  • Customizable interface
  • Easy to integrate into existing (Django) sites
  • Email update for new comments
  • Uses Markdown for easy article writing

I'm considering releasing it as another open source project. Let me know if you're interested in using it or helping out with the project.

1 Comment Tags: Blog, Django, Open Source

Objective-C Pygments

Mar 3, 2007 — Whitney Young

There's a nice extension to the Python implementation of Markdown that allows for syntax highlighting of code. It's called CodeHilite, and it allows you to use a couple of different syntax highlighting tools, one of which being Pygments. Pygments and CodeHilite are great except that Objective-C syntax highlighting hasn't been implemented in Pygments.

Fortunately the Pygments team has made it pretty easy to create a new Lexer. I quickly modified the CLexer to create an ObjectiveCLexer. It's not really ideal, but it works. If you have improvements to this Lexer, please email me and/or comment on the ticket I created for the Pygments team.

Read More...

No Comments Tags: Blog, Code, Pygments, Python

Extending Django's Model Class

Mar 2, 2007 — Whitney Young

Django's Model class is intended to be subclassed when creating a model for your application. That's about the only intended use. But what if you want to add some extra functionality to Django's model class that all of your models can use?

You would think that something like this:

from django.db import models
class M(models.Model):
  def something_special(self): pass
class MyModel(M):
  field = models.CharField(maxlength=255)

would work just fine, but it doesn't work as desired. There's a good reason why it doesn't. Here's the MySQL code that Django produces for this setup:

BEGIN;
CREATE TABLE `myapp_mymodel` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `field` varchar(255) NOT NULL
);
CREATE TABLE `myapp_m` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY
);
COMMIT;

which helps explain why it doesn't work as desired. Django considers the M class a valid model, one that can be saved to the database, so it creates an entry in the database for it. We don't need or want it in the database, though. We just want to extend the basic model class.

Read More...

7 Comments Tags: Code, Django