summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-07-15 13:17:28 +0000
committerSteven Barth <steven@midlink.org>2008-07-15 13:17:28 +0000
commitd0a622dce8163cb1f9d0a178127b7abda6c4e818 (patch)
tree44b1b5d8d01f98c24bdc0c378af5cf6004220d96 /libs
parent97ff4a156ff1aa6a4d2ab65ab13d12b4eb2651e2 (diff)
lib/cbi: Added support for multiple CBI maps per model
Diffstat (limited to 'libs')
-rw-r--r--libs/cbi/luasrc/cbi.lua12
-rw-r--r--libs/web/luasrc/dispatcher.lua18
2 files changed, 18 insertions, 12 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index 6e0845565..7370a04c4 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -57,14 +57,16 @@ function load(cbimap)
luci.util.extfenv(func, "translate", luci.i18n.translate)
luci.util.extfenv(func, "translatef", luci.i18n.translatef)
- local map = func()
+ local maps = {func()}
- if not instanceof(map, Map) then
- error("CBI map returns no valid map object!")
- return nil
+ for i, map in ipairs(maps) do
+ if not instanceof(map, Map) then
+ error("CBI map returns no valid map object!")
+ return nil
+ end
end
- return map
+ return maps
end
-- Node pseudo abstract class
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua
index 689d060d5..735e2a715 100644
--- a/libs/web/luasrc/dispatcher.lua
+++ b/libs/web/luasrc/dispatcher.lua
@@ -381,20 +381,24 @@ function cbi(model)
require("luci.template")
return function()
- local stat, res = luci.util.copcall(luci.cbi.load, model)
+ local stat, maps = luci.util.copcall(luci.cbi.load, model)
if not stat then
- error500(res)
+ error500(maps)
return true
end
- local stat, err = luci.util.copcall(res.parse, res)
- if not stat then
- error500(err)
- return true
+ for i, res in ipairs(maps) do
+ local stat, err = luci.util.copcall(res.parse, res)
+ if not stat then
+ error500(err)
+ return true
+ end
end
luci.template.render("cbi/header")
- res:render()
+ for i, res in ipairs(maps) do
+ res:render()
+ end
luci.template.render("cbi/footer")
end
end