mgymrek/pybamview — pull request #38 by robinandeer (2014-12-14 08:30:30+00:00)
Title: Flask app factory

Step 2 as planned in #35.

I'm following the conventions laid out in this Flask boilerplate repo: [imwilsonxu/fbone](https://github.com/imwilsonxu/fbone/blob/master/fbone/app.py). One of the [officially endorsed](http://flask.pocoo.org/docs/0.10/patterns/appfactories/) Flask conventions is creating an app factory (function that generates and configures the app object).

I had to make quite a lot of changes to the CLI code to get rid of some global variables.

- ``(current_)app.config``: instead of risky global variables I believe the Flask convention is to put such data in the app config object (dict). The defaults are specified in the ``settings.py`` module and in your case updated from the command line. They are always accessible to the routes via ``from flask import current_app; current_app.config``.

- MESSAGE: I moved this function to a separate module (``utils.py``) which I think makes sense. I also didn't see the point in using global variables for the distinct levels but if just tell me if you want me to skip that update :) The changes are documented in the docstring.

- Favicon route: don't know if this is entirely necessary. I updated the the ``base.html`` template to use ``url_for('static', ...)`` which I believe should work. What do you think about this approach?

- ``.travis.yml``: I've added a very basic travis config that installs the dependencies and makes sure the package installs. I ran the test using nose but they didn't pass so I thought that you wanted to look at that before including them in the travis build.