I ran into an inconvenience with the Django cache. I wanted to add my own custom cache backend without having to muck about with the Django core. This proved to be a bit challenging since the backend importer uses a complete path to the module (e.g. "django.core.cache.backends.memcached").
I did a small patch which lets you define extra backend modules without touching the Django folder. Essentially it uses the BACKENDS dictionary in core/cache/init.py to keep information about the full import paths, like this:
BACKENDS = {
# name for use in settings file --> path to the backend module
'memcached': 'django.core.cache.backends.memcached',
'locmem': 'django.core.cache.backends.locmem',
'file': 'django.core.cache.backends.filebased',
'db': 'django.core.cache.backends.db',
'dummy': 'django.core.cache.backends.dummy',
}
if hasattr(settings, "CACHE_BACKEND_MODULES"):
BACKENDS.update(settings.CACHE_BACKEND_MODULES)
So if I wanted to add a new backend in my project, I'd do something like:
settings.py:
CACHE_BACKEND_MODULES = {
'penandpaper': 'backends.cache.penandpaper'
}
and place the backend in my_app/backends/cache/.
There has been a bit of talk about it lately on the developer mailing list:
http://groups.google.com/group/django-developers/browse_thread/thread/e0fbaff909c44336