Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid double initialization of the backend class that Python can do w…

…hen using an empty string in the from list.
  • Loading branch information...
commit 81de9736935310cf5d1adabc297e0a7e1b3ae1b9 1 parent 55502ce
@brosner brosner authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 notification/backends/__init__.py
View
10 notification/backends/__init__.py
@@ -1,4 +1,6 @@
+import sys
+
from django.conf import settings
from django.core import exceptions
@@ -7,13 +9,15 @@
def load_backends():
backends = []
for label, backend_path in getattr(settings, "NOTIFICATION_BACKENDS", tuple()):
- dot = backend_path.rindex('.')
+ dot = backend_path.rindex(".")
backend_mod, backend_class = backend_path[:dot], backend_path[dot+1:]
try:
- mod = __import__(backend_mod, {}, {}, [""])
+ # import the module and get the module from sys.modules
+ __import__(backend_mod)
+ mod = sys.modules[backend_mod]
except ImportError, e:
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, "")())
+ backends.append(label, getattr(backend_mod, backend_class)())
return dict(backend_list)
Please sign in to comment.
Something went wrong with that request. Please try again.