Skip to content

Commit

Permalink
If an api_key is passed through the EmailBackend constructor, it shou…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
mattrobenolt committed Jun 16, 2011
1 parent c96c3af commit 366c8d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions postmark/django_backend.py
Expand Up @@ -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)
Expand Down

0 comments on commit 366c8d1

Please sign in to comment.