Or, developing Django data applications without a database.
In recent months I have been working intensively on a user interface to a data store that lives behind a web services API. While this might not be considered a natural fit for Django, the smart de-coupling of URLs, views, and templates from data models means that the former retain their value even without the latter. And hey, it’s all just Python, right? Django models are just one way to handle data in your application, albeit a very convenient and powerful one when dealing with an RDBMS.
Before working on this project, I had already developed two other Django apps based on data sources accessed via HTTP, both of which were read-only, which of course made things quite a bit simpler. The first of these was an XML-RPC interface (built with django_xmlrpc, Python’s standard xmlrpclib module and python-ldap) to an LDAP directory. I manage user and group information for a number of staff applications, including Django itself, for which it is very useful to draw upon a central source of personnel data. The Django-based service provides convenient methods for common operations while hiding the complexities of LDAP connections and search queries.
The second app dealt with requests to web services of a library catalog which return content in a custom XML format. Since only HTTP GET requests were required, I used Python’s standard urllib and urllib2 modules for the request/response handling, and lxml.etree for the XML parsing and XSLT application (see also my previous post on the virtues of lxml).
The current project, as opposed to the previous two, involves both read and write actions on the backend data store. Also, because the web services API implements a REST architecture, the “client” code I was tasked with has to support a wider range of HTTP request methods (not just GET and POST) and responses. Finally, the client code stack includes a full-blown user interface (the ultimate purpose of the app) for managing the backend data. In my next post, I’ll talk about how I broke down the problem.