Using Django for USGIN

Thought and ideas about using Django to accomplish USGIN-related... things.

Updated URI Redirection Engine

I've made a new version of the URI redirection engine that runs in Django (see the original post here). The tool allows you to provide a list of URI patterns that identify specific resources, and redirect traffic that matches that pattern to a URL where a representation of the resource exists. It allows for content-negotiation, and the new version also begins to build infrastructure by which various instances of the application can communicate with each other.

Each instance of the application is informed about the existence of various registers, which are essentially sets of URIs. The application may or may not know how to resolve URIs that are a part of any given register, but can send incoming requests to others servers capable of resolving that register's URIs.

PyGreSQL: This will be useful!

PyGreSQL is a python library that allows you to write python code to interact with a PostgreSQL database. I can see some utility here if I start wanting to write Django methods that do things like create views of some of my tables.

May be useful in not too long! Don't forget about it!

Documentation: http://pygresql.org/pg.html

Installation:

sudo apt-get install python-pygresql

Use:

Postgres COPY for CSV importing

Working on some integration between Geoserver, Django and NCGMP geodatabases, I often need to use PostgreSQL's COPY command to import data from CSV files into PostgreSQL. Here are some tips:

URI Redirection Engine (with pictures!)

Here are a few screenshots to give a taste of what it is like to use our new Django app to manage a set of URI redirections:

Administration Overview:

For any URI-Scheme: Basically, the Django app allows you to control a listing of MIME Media Types, and Rewrite rules.

generic admin page

USGIN URI-Scheme: The same basic structure, but the USGIN-specific app allows you to control a listing of Name Authorities and Resource Types, as described in this post.

Usgin scheme admin

 

Listing of Rewrite Rules: A nice overview of what rewrite rules you have in place, and a mechanism for searching for the one you might need to adjust.

rule list

 

Creation of a Rewrite Rule:

URI dereferencing with Django / HTTP Content Negotiation

I've been building a Django app that essentially allows for the dereferencing of URIs that follow the USGIN Scheme. The engine also does some content-negotiation by reading HTTP GET accept-headers and responding with an appropriate file located somewhere on the internet. I had never even heard about content negotiation before embarking on this, and here are a few things that I learned:

 

Redirection Engine for USGIN-Compliant URI Resolution

A common problem we run into is the unique identification of resources. This is a very broad statement because it represents a very broad problem. We have identification schemes for all kinds of things: people have names, web pages have URLs, books have ISBN numbers, etc. For the USGIN system to work smoothly, we need an identification scheme for resources that are part of the network. In USGIN we use Universal Resource Identifiers (URIs) which follow a specific format. For more information about the format, and for more background, see this post on lab.usgin.org.  

Once we have this identification scheme built, it is important that the URIs can be dereferenced, or in other words that they are resolvable. We would like a user to be able to put the URI of a particular feature into the address bar of their web browser, push enter, and be presented with some sort of representation of their resource of interest. This is the niche that our Django-based redirection engine it trying to fill.

Django Setup

Introduction

I'm relatively new to Django, and maybe to servers in general, but setting up Django is a chore. Or at least figuring out how to set it up is. There is no installer. You have to have a pretty good understanding of how your HTTP server (IIS, Apache, whatever) works before you're going to be able to get anywhere. Then you'll have to know how to set up quite a few ancillary applications (e.g. Python, WSGI, FastCGI, Flup, MySQL, PostgreSQL). The details of which other applications you want to set up depend entirely on the evironment you're building - so that means it is a little different every time - and that means it is pretty hard to write one single "walkthrough" for how you should do it.

What I want to do here is detail my setup, and along the way make some suggestions about what seems to make things easier. So here goes:

Suggestion: Use Ubuntu (Most recent stable version, always.)

I say this because that apt system really makes installations a breeze. I fumbled for a while to try and setup WSGI (a module for Apache) to work on my Windows machine, to no avail. In Ubuntu it is so easy:

Syndicate content