mitsuhiko/flask — pull request #921 by uniphil (2013-12-03 21:18:14+00:00)
Title: Fix relative send_from_directory for package apps

The bug is basically: if a relative directory path is provided to [`send_from_directory`](https://github.com/mitsuhiko/flask/blob/master/flask/helpers.py#L585), in a [package application](http://flask.pocoo.org/docs/patterns/packages/) things get messed up, and it doesn't work at all:

I threw a longer explanation of the current issue [in a gist](https://gist.github.com/uniphil/7777590), and made a simple repo showing the problem [here](https://github.com/uniphil/flask-package-sendfile-test).

My proposal is to expand the `directory` argument of `send_from_directory(directory, filename, **options)` to an absolute path using `current_app.root_path` if it is not absolute.

This change will affect the arguments passed to `send_file` for module apps, but it's just breaking out the absolute path earlier, so I don't _think_ this should break anything that currently works? All the tests pass.

I also couldn't figure out where a test should go for this, or if a test should even be added. I couldn't find any tests for `send_from_directory` (there are some for `send_file`), and I also didn't know the best way for using a package app in a test. If you'd like tests added for this behavior I'd be happy to write them with a few pointers on how to approach it.