Offline Django?

by Marty Alchin on June 1, 2007 about Django

A few weeks back, I got bored for a bit and started trying to emulate Django’s declarative model syntax in JavaScript. This was a fairly useless exercise, but one that seemed entertaining at the time. However, now that I look into some of the information on how Google Gears helps makes web applications available offline, I wonder it might actually be worth the time to make it happen.

Essentially Google Gears uses a combination of a fake server to store static content, a local relational database (SQLite!) and a “WorkerPool” that’s designed to provide asynchronous code execution, since JavaScript doesn’t natively support asynchronous execution. The first “A” in Ajax is indeed “Asynchronous”, but that refers not to JavaScript execution, but the fact that the HTTP request (which would then contain server-side execution) doesn’t block JavaScript. Since Google Gears doesn’t have a server to run custom code during the asynchronous HTTP request, it provides the WorkerPool instead, so that you can have JavaScript perform a similar purpose.

So, for Django applications to work offline, an ideal situation would be to have a JavaScript-based subset of Django functionality that’s designed to work with SQLite and Google’s WorkerPool. This way, applications could dump portions of their DB, along with JavaScript versions of their models, into a cilent’s browser, allowing the application (or, at least, parts of it) to continue working as expected.

Since I’m working on a few projects for clients without physical office space, it’d be excellent to have a client management system that’s capable of going offline, so I can take my laptop into their homes, restaurants, or wherever else I might not be able to get to the Internet.

I won’t pretend I have it working or anything, but I’ll certainly be doing some research on the topic, and I hope to have something to show for it before too long.