Skip to content
This repository has been archived by the owner on Jul 24, 2018. It is now read-only.

Commit

Permalink
Add a way to disable a backend alltogether.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Jun 5, 2014
1 parent c051ba3 commit 5209ea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion fmn/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ def matches(filter, message, valid_paths, config):
def load_preferences(session, config, valid_paths):
""" Every rule for every filter for every context for every user.
Any preferences in the DB that are for contexts that are disabled in the
config are omitted here.
This is an expensive query that loads, practically, the whole database.
"""
preferences = session.query(fmn.lib.models.Preference).all()
return [preference.__json__() for preference in preferences]
return [preference.__json__() for preference in preferences
if preference.context.name in config['fmn.backends']]


def load_rules(root='fmn.rules'):
Expand Down
4 changes: 3 additions & 1 deletion fmn/lib/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def setUp(self):
os.unlink(dbfile)
self.sess = fmn.lib.models.init(DB_PATH, debug=False, create=True)

self.config = {}
self.config = {
'fmn.backends': ['irc', 'email', 'android'],
}
self.valid_paths = fmn.lib.load_rules(
root='fmn.lib.tests.example_rules')

Expand Down

0 comments on commit 5209ea7

Please sign in to comment.