diff options
author | Steven Barth <steven@midlink.org> | 2008-08-24 16:22:49 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-24 16:22:49 +0000 |
commit | 451eacf8da90980f9b860db445cb0b04558e9d31 (patch) | |
tree | 2cc162289a95bab11819b012f17ccabfa6b6f004 /libs/cbi | |
parent | 1946740198db90e203aa0d9cc481f5ff787b8257 (diff) |
CBI-UVL integration part #1
Diffstat (limited to 'libs/cbi')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 295998e924..8da7bc7263 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -30,6 +30,7 @@ require("luci.template") require("luci.util") require("luci.http") require("luci.model.uci") +require("luci.uvl") local uci = luci.model.uci local class = luci.util.class @@ -160,6 +161,9 @@ function Map.__init__(self, config, ...) if not uci.load_config(self.config) then error("Unable to read UCI data: " .. self.config) end + + self.validator = luci.uvl.UVL() + self.scheme = self.validator:get_scheme(self.config) end function Map.render(self, ...) @@ -535,13 +539,22 @@ NamedSection - A fixed configuration section defined by its name ]]-- NamedSection = class(AbstractSection) -function NamedSection.__init__(self, map, section, type, ...) - AbstractSection.__init__(self, map, type, ...) +function NamedSection.__init__(self, map, section, stype, ...) + AbstractSection.__init__(self, map, stype, ...) Node._i18n(self, map.config, section, nil, ...) + -- Defaults + self.addremove = false + + -- Use defaults from UVL + if self.map.scheme and self.map.scheme.sections[self.sectiontype] then + local vs = self.map.scheme.sections[self.sectiontype] + self.addremove = not vs.unique and not vs.required + self.dynamic = vs.dynamic + end + self.template = "cbi/nsection" self.section = section - self.addremove = false end function NamedSection.parse(self) @@ -587,8 +600,15 @@ function TypedSection.__init__(self, map, type, ...) self.template = "cbi/tsection" self.deps = {} - self.anonymous = false + + -- Use defaults from UVL + if self.map.scheme and self.map.scheme.sections[self.sectiontype] then + local vs = self.map.scheme.sections[self.sectiontype] + self.addremove = not vs.unique and not vs.required + self.dynamic = vs.dynamic + self.anonymous = not vs.named + end end -- Return all matching UCI sections for this TypedSection |