forked from pinax/pinax-notifications
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pluggable-backends: Implemented backend loading from settings.
git-svn-id: https://django-notification.googlecode.com/svn/branches/pluggable-backends@57 590c3fc9-4838-0410-bb95-17a0c9b37ca9
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,19 @@ | |||
|
|
||
from django.conf import settings | |||
from django.core import exceptions | |||
|
|||
from base import BaseBackend | from base import BaseBackend | ||
|
|||
def load_backends(): | |||
backends = [] | |||
for label, backend_path in getattr(settings, "NOTIFICATION_BACKENDS", tuple()): | |||
dot = backend_path.rindex('.') | |||
backend_mod, backend_class = backend_path[:dot], backend_path[dot+1:] | |||
try: | |||
mod = __import__(backend_mod, {}, {}, [""]) | |||
except ImportError, e: | |||
raise exceptions.ImproperlyConfigured, 'Error importing notification backend %s: "%s"' % (backend_mod, e) | |||
# add the backend label and an instaniated backend class to the | |||
# backends list. | |||
backends.append(label, getattr(backend_mod, "")()) | |||
return dict(backend_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters