scoped session factory

Rather than creating a new session / connection in every place that it is required use a scoped session factory (scoped to the thread) to manage connections as described here: http://docs.sqlalchemy.org/en/rel_0_9/orm/session.html?highlight=session#using-thread-local-scope-with-web-applications

@dannyroberts @esoergel @czue 
Be careful with a bare raise. It's not perfect.

```
>>> try:
...     raise AssertionError("bang!")
... except Exception:
...     try:
...         raise Exception("stop!")
...     except Exception:
...         pass
...     raise
...
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
Exception: stop!
```
If you want to safely re-raise an exception you have to do something like this:

```
>>> import sys
>>> try:
...     raise AssertionError("bang!")
... except Exception:
...     exc_type, exc_value, exc_tb = sys.exc_info()
...     try:
...         raise Exception("stop!")
...     except Exception:
...         pass
...     raise exc_type, exc_value, exc_tb
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
AssertionError: bang!
```