Application factory cleanup

* Cleanup Flask application factory to make application
  assembly more clear.
Package order aware template loading

* Adds Jinja2 template loader that respect template loading
  order according to the PACKAGES configuration. This is needed
  for overlays like Inspire and Zenodo to customize e.g.
  'page.html'.
template: fix jinja loader order awareness
template: tests for template order loading
Merge remote-tracking branch 'adrianp-github/pu' into pu
session: fixes login when no cache backend exists

Signed-off-by: Adrian-Tudor Panescu <adrian.tudor.panescu@cern.ch>
requirements: version bumps

* Bumps MySQL-python and beautifulsoup4 to newer versions.

Signed-off-by: Adrian-Tudor Panescu <adrian.tudor.panescu@cern.ch>