Make links database api work regardless if you pass it doc_id or the document.
PEP8 fixes.