Django : using a seperate memcached cloud for sessions

When you are using a platform like django you realise how slow sessions can get when you are using the database as a backend. The problem of using a memory cache like memcached is the fact that when you restart the server to refresh the cache or remove stale objects, the problem is that you lose your sessions data and a lot of people using your site get logged out. The only solution to this problem is to use 2 memcached instances , one for your regular python objects and another for your sessions objects … this is not a default feature in Django....

November 18, 2008 · 2 min · 400 words · Me

Django : using HTTP authentication for your views

This is a small tutorial on how to use HTTP authentication for your site. Firstly you need to copy this file to httpauth.py and place it at /httpauth.py import base64 from django.contrib.auth.models import User from django.http import HttpResponse from django.contrib.auth import authenticate, login ############################################################################# def view_or_basicauth(view, request, test_func, realm = “”, *args, **kwargs): """ This is a helper function used by both ‘’logged_in_or_basicauth’’ and ‘‘has_perm_or_basicauth’’ that does the nitty of determining if they are already logged in or if they have provided proper http-authorization and returning the view if all goes well, otherwise responding with a 401....

November 15, 2008 · 3 min · 526 words · Me