Zero-downtime deployments

For some time now I’ve been thinking about all the different approaches that I have seen and heard with the goal of zero-downtime deployment for a horizontally-scaled application that relies on a database or some form of persistent storage. On most of the projects that I have worked on this was not a requirement, although a speedy and automated deployment was preferred. However, other projects were for websites and applications that formed the backbone of a 24/7 company and as such the idea of even a couple of minutes downtime was unacceptable....

Django RESTful resources

Last year I blogged about a neat trick in Django to have multiple views per HTTP verb. Since then I’ve been playing with RESTful applications and decided to see if there was a nicer way to expose “resources” in Django. The following is what I’ve come up with so far. Listing: router.py from django.http import Http404, HttpResponseNotAllowed def get_handler_method(request_handler, http_method): try: handler_method = getattr(request_handler, http_method.lower()) if callable(handler_method): return handler_method except AttributeError: pass class Resource: http_methods = ['GET', 'POST', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'] @classmethod def dispatch(cls, request, *args, **kwargs): request_handler = cls() if request....

Django and multiple methods per url pattern

HTTP verbs are not used to determine the route to a view method by deliberate design in Django. Sometimes I find it useful to be able to specify different methods for the same url pattern - one per HTTP verb. The Django book contains an interesting example of how this can be done using the django.conf.urls.defaults.url method to separate POST from GET processing. I’ve extended the example to provide handling to cover the standard HTTP verbs....