Allow kwargs overrides for (nearly) all settings

* Update utils.get_anymail_setting to support
  kwargs override of django.conf.settings values
* Use the updated version everywhere
* Switch from ImproperlyConfigured to
  AnymailConfigurationError exception
  (anticipates feature_wehooks change)

Closes #12
This commit is contained in:
medmunds
2016-04-29 14:34:34 -07:00
parent 6b415eeaae
commit df881fdb75
10 changed files with 124 additions and 38 deletions

View File

@@ -125,8 +125,15 @@ class AnymailSerializationError(AnymailError, TypeError):
super(AnymailSerializationError, self).__init__(message, *args, **kwargs)
# This deliberately doesn't inherit from AnymailError
class AnymailImproperlyInstalled(ImproperlyConfigured, ImportError):
class AnymailConfigurationError(ImproperlyConfigured):
"""Exception for Anymail configuration or installation issues"""
# This deliberately doesn't inherit from AnymailError,
# because we don't want it to be swallowed by backend fail_silently
class AnymailImproperlyInstalled(AnymailConfigurationError, ImportError):
"""Exception for Anymail missing package dependencies"""
def __init__(self, missing_package, backend="<backend>"):
message = "The %s package is required to use this backend, but isn't installed.\n" \
"(Be sure to use `pip install django-anymail[%s]` " \