divio/django-cms — pull request #2606 by foobacca (2014-02-09 13:44:56+00:00)
Title: don't swallow ImportError due to importing app that exists

Previously get_module() would try swallow the ImportError, but there are
two causes for the ImportError - the module file doesn't exists, or
importing the module file causes an ImportError. We want to swallow the
first but not the second.

This commit uses the imp module - imp.find_module() looks for the module
and will cause an ImportError if the module does not exist. But it will
not actually run the file code. So the try/except block is put around
imp.find_module(). If there was no ImportError at that point, we then
to load_module() outside the try/except block, and if that fails we die
here immediately.