Permalink
Browse files

Allow the user to define spam_sensitivity overrides for backends.

  • Loading branch information...
1 parent 9504ea4 commit 94f0e39a717a4b3f62ed96373796b76f8b0ba820 @brosner brosner committed Jan 7, 2009
Showing with 13 additions and 3 deletions.
  1. +10 −2 notification/backends/__init__.py
  2. +3 −1 notification/backends/base.py
@@ -8,7 +8,14 @@
def load_backends():
backends = []
- for label, backend_path in getattr(settings, "NOTIFICATION_BACKENDS", tuple()):
+ for bits in getattr(settings, "NOTIFICATION_BACKENDS", tuple()):
+ if len(bits) == 2:
+ label, backend_path = bits
+ spam_sensitivity = None
+ elif len(bits) == 3:
+ label, backend_path, spam_sensitivity = bits
+ else:
+ raise exceptions.ImproperlyConfigured, "NOTIFICATION_BACKENDS does not contain enough data."
dot = backend_path.rindex(".")
backend_mod, backend_class = backend_path[:dot], backend_path[dot+1:]
try:
@@ -19,5 +26,6 @@ def load_backends():
raise exceptions.ImproperlyConfigured, 'Error importing notification backend %s: "%s"' % (backend_mod, e)
# add the backend label and an instantiated backend class to the
# backends list.
- backends.append(label, getattr(backend_mod, backend_class)(label))
+ backend_instance = getattr(backend_mod, backend_class)(label, spam_sensitivity)
+ backends.append(label, backend_instance)
return dict(backend_list)
@@ -5,8 +5,10 @@ class BaseBackend(object):
"""
The base backend.
"""
- def __init__(self, label):
+ def __init__(self, label, spam_sensitivity=None):
self.label = label
+ if spam_sensitivity is not None:
+ self.spam_sensitivity = spam_sensitivity
def can_send(self, user, notice_type):
"""

0 comments on commit 94f0e39

Please sign in to comment.