Prevent meta-class error in top-level imports.

Extended the `ImportError` handling hack to correctly handle the
case where we cannot import submodules AND someone is extending
one of the exported classes.  Previously ContentMixin and
ContentSettings were functions when ImportError was raised which
causes really confusing errors.

The correct solution here is to stop exporting stuff at the top-
level and require clients to import from modules but that is for
another day.
This commit is contained in:
Dave Shawley 2016-03-16 09:19:04 -04:00
parent 14f3533517
commit 242a0590e6

View file

@ -14,8 +14,12 @@ except ImportError as error: # pragma no cover
def _error_closure(*args, **kwargs):
raise error
ContentMixin = _error_closure
ContentSettings = _error_closure
class ErrorClosureClass(object):
def __init__(self, *args, **kwargs):
raise error
ContentMixin = ErrorClosureClass
ContentSettings = ErrorClosureClass
add_binary_content_type = _error_closure
add_text_content_type = _error_closure
set_default_content_type = _error_closure