Make configure_logging idempotent; move API response configuration.

It doesn't make sense to globally configure an app's error handlers if it uses
the ns_api blueprint, so move the errorhandler installation to api/srv.py.
Remove module-level imports from migrations.

The problem here is that alembic imports all the migration scripts when we
check the current alembic revision on startup. This can break as the code
changes later. In particular, we may end up importing stuff that gevent later
monkeypatches, causing strange breakages.