Blog Archive for April 28, 2010

Python Metaclasses

April 28, 2010

When you create a class in python, the mechanism used comes from a class called type. It is possible to subclass from type and change the create class behaviour.

This example is taken from the Django model form. The model form automatically creates attributes on itself from the model …

Memcached Sessions in Django

April 28, 2010

I needed non-database sessions in a Django app. This can be achieved using memcached on a server, and then configuring Django to store session information in it.

Memcached

On a fedora box installing memcached itself was as simple as:

yum install memcached

Django settings.py

CACHE_BACKEND = 'memcached://server:11211/'
SESSION_ENGINE = 'django.contrib.sessions.backends.cache' …