azavea/OTM2 — pull request #148 by ahinz (2013-08-07 14:26:09+00:00)
Title: Add in scalar user defined fields

Scalar user defined fields can be added to any model by using a parent
class of: UDFModel (from treemap.udf).

UDFModel provides the `udf_scalar_values` field. This field allows udfs
defined using a `UserDefinedFieldDefinition` to be accessed using
standard python square-bracket syntax.

For example, if we have a `UserDefinedFieldDefinition` defined like:

```
datatype = [{'type': 'int'}]
name = 'Plot Age'
```

We can update the field using:

```
p = Plot.objects.get(pk=4)
old_age = p.udf_scalar_values['Plot Age']

p.udf_scalar_values['Plot Age'] = 4
p.save_with_user(some_user)
```

Scalar UDFs interop directly with the audit and authorizable system. In
the above example the user (`some_user`) must have `WRITE_DIRECTLY` or
`WRITE_WITH_AUDIT` privileges on 'Plot.Plot Age'.

Since this uses postgres's hstore feature we need to update our build
tools to install it:

```
bash> sudo apt-get install postgresql-contrib
psql> CREATE EXTENSION hstore;
```