Just a small proposition for your "better exception" comment: I changed the type of caught exceptions to sqlalchemy.orm.exc.NoResultFoundException. With this, if .one() function fails because no result was found, the exception is raised and abort(404) is executed. If another exception is raised, it should be intercepted by Flask, which will then display the 500 error page.
Hi again,
Just a small proposition for your "better exception" comment: I changed the type of caught exceptions to sqlalchemy.orm.exc.NoResultFoundException. With this, if .one() function fails because no result was found, the exception is raised and abort(404) is executed. If another exception is raised, it should be intercepted by Flask, which will then display the 500 error page.
Note that it's not mandatory to "return" before the abort() function, as mentioned here http://flask.pocoo.org/docs/quickstart/#redirects-and-errors .
Do you see anything else to improve this a little bit more?
Thanks !