From 798031f9cd152fc29906c7a115c07dcf4f448377 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Tue, 9 Jun 2015 17:12:59 +0200 Subject: [PATCH] Comments on settings system --- src/util/settings.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/settings.lua b/src/util/settings.lua index dde2666..52c52d5 100644 --- a/src/util/settings.lua +++ b/src/util/settings.lua @@ -161,22 +161,27 @@ end]]-- function M.get(key) --log:info("settings:get: "..utils.dump(key)) key = replaceDots(key) + + -- retrieve settings's base settings from conf_defaults.lua local base = getBaseKeyTable(key) - if not base then return nil,ERR_NO_SUCH_KEY end + -- check which uci section to read. + -- By default it will read from the general section, but if a base setting contains a subSection it will check that subSection local section = UCI_CONFIG_SECTION; if base.subSection ~= nil then section = M.get(base.subSection) end - + + -- get setting from uci local uciV,msg = uci:get(UCI_CONFIG_NAME, section, key) if not uciV and msg ~= nil then local errorMSG = "Issue reading setting '"..utils.dump(key).."': "..utils.dump(msg); log:info(errorMSG) return nil, errorMSG; end - + + -- convert uci value into proper lua value local uciV = fromUciValue(uciV, base.type) if uciV ~= nil then -- returning value from uci