Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Give priority to api_key passed through the constructor of the EmailBackend #14

Merged
merged 1 commit into from

2 participants

@mattrobenolt

If an api_key is passed through the EmailBackend constructor, it should take priority over the global settings.POSTMARK_API_KEY. Without this, you are not able to override the global variable for a one-off call.

@mattrobenolt mattrobenolt If an api_key is passed through the EmailBackend constructor, it shou…
…ld take priority over the global settings.POSTMARK_API_KEY. Without this, you are not able to override the global variable for a one-off call.
366c8d1
@themartorana themartorana merged commit 5e1df27 into themartorana:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 16, 2011
  1. @mattrobenolt

    If an api_key is passed through the EmailBackend constructor, it shou…

    mattrobenolt authored
    …ld take priority over the global settings.POSTMARK_API_KEY. Without this, you are not able to override the global variable for a one-off call.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 postmark/django_backend.py
View
4 postmark/django_backend.py
@@ -32,8 +32,8 @@ def __init__(self, api_key=None, default_sender=None, **kwargs):
Initialize the backend.
"""
super(EmailBackend, self).__init__(**kwargs)
- self.api_key = getattr(settings, 'POSTMARK_API_KEY', api_key)
- if not self.api_key:
+ self.api_key = api_key if api_key is not None else getattr(settings, 'POSTMARK_API_KEY', None)
+ if self.api_key is None:
raise ImproperlyConfigured('POSTMARK API key must be set in Django settings file or passed to backend constructor.')
self.default_sender = getattr(settings, 'POSTMARK_SENDER', default_sender)
self.test_mode = getattr(settings, 'POSTMARK_TEST_MODE', False)
Something went wrong with that request. Please try again.