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

@@ -14,8 +14,10 @@ class PostmarkBackend(AnymailRequestsBackend):
def __init__(self, **kwargs):
"""Init options from Django settings"""
self.server_token = get_anymail_setting('POSTMARK_SERVER_TOKEN', allow_bare=True)
api_url = get_anymail_setting("POSTMARK_API_URL", "https://api.postmarkapp.com/")
esp_name = self.esp_name
self.server_token = get_anymail_setting('server_token', esp_name=esp_name, kwargs=kwargs, allow_bare=True)
api_url = get_anymail_setting('api_url', esp_name=esp_name, kwargs=kwargs,
default="https://api.postmarkapp.com/")
if not api_url.endswith("/"):
api_url += "/"
super(PostmarkBackend, self).__init__(api_url, **kwargs)