alphagov/backdrop — pull request #297 by robyoung (2014-05-24 10:47:28+00:00)
Title: Refactor data layer step 1

Introduce the beginnings of a simplified storage engine API in the form of the `MongoStorageEngine`. This pull request introduces the class and implements and integrates a couple of the simpler methods on it. The final goal is to better separate the underlying database from the rest of the application and thus allowing the processing pipeline to be more easily refactored.

The interface for the storage engine will ultimately look like this:
```python
class MongoStorageEngine:
# return true if the database is alive, false otherwise
def alive():
# returns true if the data set exists
def dataset_exists(data_set):
# create the data set with the appropriate parameters
def create_dataset(data_set, size):
# get the update time of the most recently updated record in a data set
def get_last_updated(data_set):
# save a record in a data set (all preprocessing happens before it gets here)
def save(data_set, record):
# query a data set and return a flat list of results
def query(data_set, query):
```

This pull request implements `alive`, `dataset_exists` and `create_dataset`.

**WARNING**
This pull request and the next few will introduce some redundancy and some duplication. I've done it like this so that it can be integrated in small steps.