Add formal support for looking up static files for extensions.

Review Request #4742 — Created Oct. 13, 2013 and submitted — Latest diff uploaded




Add formal support for looking up static files for extensions.

This introduces support for checking an extension's static/ directory
for static media lookups. If provided, the contents will be checked when
looking up a static URL beginning with the extension's ID. This will
match regardless of the filesystem path for the extension, meaning it
will work nicely without copying files or symlinking during the
development of an extension.

There's a new static media finder, ExtensionFinder, that must be placed
in STATICFILES_FINDERS. This finder is responsible for looking up
files prefixed by an extension ID.

In a production setup, it's important to install media files into a
common place when enabling an extension, so that the web server can
serve them up without going through Django's static files registry.
For that, when enabling an extension, the static files will be copied
over, but only when settings.DEBUG is False. In a development setup,
/static/ is based on the finders and not the filesystem (so long as a
static/ directory does not exist), so it will just use ExtensionFinder
to look up, and not look through the static/ directory.

Tested with two extensions: One using the old htdocs-bundled media files,
and one using static media. Saw the warning on the htdocs one. In both
cases, media files were served up correctly.

Verified after enabling an extension using the static files that the
files were not copied over but were accessible through the /static/ directory
using the finders. Switched out of a DEBUG setup and saw that it installed
to the static/ext/ directory.