summaryrefslogtreecommitdiffstats
path: root/module/config
diff options
context:
space:
mode:
Diffstat (limited to 'module/config')
-rw-r--r--module/config/ConfigManager.py12
-rw-r--r--module/config/ConfigParser.py4
2 files changed, 15 insertions, 1 deletions
diff --git a/module/config/ConfigManager.py b/module/config/ConfigManager.py
index 8d908abaf..ff638fd71 100644
--- a/module/config/ConfigManager.py
+++ b/module/config/ConfigManager.py
@@ -42,6 +42,7 @@ class ConfigManager(ConfigParser):
# Entries are saved as (user, section) keys
self.values = {}
# TODO: similar to a cache, could be deleted periodically
+ # TODO: user / primaryuid is a bit messy
def save(self):
self.parser.save()
@@ -78,6 +79,8 @@ class ConfigManager(ConfigParser):
self.values[user, section] = {}
self.core.print_exc()
+ return self.values[user, section]
+
@convertKeyError
def set(self, section, option, value, sync=True, user=None):
""" set config value """
@@ -107,7 +110,7 @@ class ConfigManager(ConfigParser):
def delete(self, section, user=False):
""" Deletes values saved in db and cached values for given user, NOT meta data
Does not trigger an error when nothing was deleted. """
- user = user.primary if user else None
+ user = primary_uid(user)
if (user, section) in self.values:
del self.values[user, section]
@@ -132,3 +135,10 @@ class ConfigManager(ConfigParser):
for name, config in self.config.iteritems():
yield name, config, values[name] if name in values else {}
+
+ def getSection(self, section, user=None):
+ if section in self.parser and primary_uid(user) is None:
+ return self.parser.getSection(section)
+
+ values = self.loadValues(section, user)
+ return self.config.get(section), values
diff --git a/module/config/ConfigParser.py b/module/config/ConfigParser.py
index 2f974b75e..bf9192270 100644
--- a/module/config/ConfigParser.py
+++ b/module/config/ConfigParser.py
@@ -168,6 +168,10 @@ class ConfigParser:
for name, config in self.config.iteritems():
yield name, config, self.values[name] if name in self.values else {}
+ def getSection(self, section):
+ """ Retrieves single config as tuple (section, values) """
+ return self.config[section], self.values[section] if section in self.values else {}
+
def addConfigSection(self, section, name, desc, long_desc, config):
"""Adds a section to the config. `config` is a list of config tuples as used in plugin api defined as:
The order of the config elements is preserved with OrderedDict