summaryrefslogtreecommitdiffstats
path: root/module/config/ConfigManager.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-06 15:54:52 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-06 15:54:52 +0100
commit6f8b5347dfa119a3df21f4ca8ba8c2b1537a726a (patch)
tree627c4d99f0aaa4c8022b70b3ebe72f201d924dd6 /module/config/ConfigManager.py
parentremoved unneeded stuff (diff)
downloadpyload-6f8b5347dfa119a3df21f4ca8ba8c2b1537a726a.tar.xz
first working parts of config api
Diffstat (limited to 'module/config/ConfigManager.py')
-rw-r--r--module/config/ConfigManager.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/module/config/ConfigManager.py b/module/config/ConfigManager.py
index 4898b0c66..eb96a49f6 100644
--- a/module/config/ConfigManager.py
+++ b/module/config/ConfigManager.py
@@ -5,7 +5,7 @@ from new_collections import OrderedDict
from module.Api import InvalidConfigSection
from module.common.json_layer import json
-from module.utils import from_string
+from module.utils import from_string, primary_uid
from ConfigParser import ConfigParser
@@ -57,7 +57,7 @@ class ConfigManager(ConfigParser):
else:
# We need the id and not the instance
# Will be None for admin user and so the same as internal access
- user = user.primary if user else None
+ user = primary_uid(user)
try:
# Check if this config exists
# Configs without meta data can not be loaded!
@@ -87,7 +87,7 @@ class ConfigManager(ConfigParser):
changed = self.parser.set(section, option, value, sync)
else:
# associated id
- user = user.primary if user else None
+ user = primary_uid(user)
data = self.config[section].config[option]
value = from_string(value, data.type)
old_value = self.get(section, option)
@@ -113,6 +113,22 @@ class ConfigManager(ConfigParser):
self.db.deleteConfig(section, user)
+ def iterCoreSections(self):
+ return self.parser.iterSections()
- def iterSections(self):
- pass \ No newline at end of file
+ def iterSections(self, user=None):
+ """ Yields: section, metadata, values """
+
+ user = primary_uid(user)
+ values = self.db.loadConfigsForUser(user)
+
+ # Every section needs to be json decoded
+ for section, data in values.items():
+ try:
+ values[section] = json.loads(data) if data else {}
+ except ValueError:
+ values[section] = {}
+ self.core.print_exc()
+
+ for name, config in self.config.iteritems():
+ yield name, config, values[name] if name in values else {}