diff options
author | Simo Sorce <simo@redhat.com> | 2014-10-08 18:13:15 -0400 |
---|---|---|
committer | Patrick Uiterwijk <puiterwijk@redhat.com> | 2014-10-24 18:02:20 +0200 |
commit | 19d7bd78989ae6ee603ff4f49517fd25f6bc79d0 (patch) | |
tree | 030ec00a4f902dedbde5e3d74ccefcd5468d28f4 | |
parent | b7c27f28617f6fb22491f23130669bcb302d8f34 (diff) | |
download | ipsilon.git-19d7bd78989ae6ee603ff4f49517fd25f6bc79d0.tar.gz ipsilon.git-19d7bd78989ae6ee603ff4f49517fd25f6bc79d0.tar.xz ipsilon.git-19d7bd78989ae6ee603ff4f49517fd25f6bc79d0.zip |
Add helpers to store per plugin user preferences
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
-rwxr-xr-x | ipsilon/util/data.py | 11 | ||||
-rwxr-xr-x | ipsilon/util/user.py | 10 |
2 files changed, 19 insertions, 2 deletions
diff --git a/ipsilon/util/data.py b/ipsilon/util/data.py index 78fa5ab..5672d04 100755 --- a/ipsilon/util/data.py +++ b/ipsilon/util/data.py @@ -317,7 +317,16 @@ class UserStore(Store): super(UserStore, self).__init__('user.prefs.db') def save_user_preferences(self, user, options): - return self.save_options('users', user, options) + self.save_options('users', user, options) + + def load_user_preferences(self, user): + return self.load_options('users', user) + + def save_plugin_data(self, plugin, user, options): + self.save_options(plugin+"_data", user, options) + + def load_plugin_data(self, plugin, user): + return self.load_options(plugin+"_data", user) class TranStore(Store): diff --git a/ipsilon/util/user.py b/ipsilon/util/user.py index 47cb23c..3a4962d 100755 --- a/ipsilon/util/user.py +++ b/ipsilon/util/user.py @@ -40,7 +40,7 @@ class User(object): def _get_user_data(self, username): store = UserStore() - return store.load_options('users', username) + return store.load_user_preferences(username) def reset(self): self.name = None @@ -98,6 +98,14 @@ class User(object): # TODO: implement setting sites via the user object ? raise AttributeError + def save_plugin_data(self, plugin, data): + store = UserStore() + store.save_plugin_data(plugin, self.name, data) + + def load_plugin_data(self, plugin): + store = UserStore() + return store.load_plugin_data(plugin, self.name) + class UserSession(Log): def __init__(self): |