Move get_job() into db.py

Another step in encapsulating all model code in db.py.

get_metadata() and get_logs() (which are only called by get_job())
also move into db.py and become private functions.

Also add docstrings
Rename engine -> ENGINE

Valid name for a global constant
Rename metadata -> _METADATA

Valid name for a global constant.

Also this is no longer used outside of db.py, so take the opportunity to
make it private.

This also removes some problems with some functions redefining the name
"metadata".
Rename jobs_table -> JOBS_TABLE

Valid name for a constant.
Rename metadata_table -> METADATA_TABLE

Valid name for a constant.
Rename logs_table -> LOGS_TABLE

Valid name for a constant.
Correct some docstrings
Don't use map()

List comprehensions and simple for loops are much clearer.
Merge branch 'master' of github.com:ckan/ckan-service-provider