libs/cbi: Added magic ;-)
[project/luci.git] / libs / web / luasrc / dispatcher.lua
index 576db36..9ba74c4 100644 (file)
@@ -126,9 +126,12 @@ function dispatch(request)
        
        local c = context.tree
        local track = {}
+       local args = {}
+       local n
 
        for i, s in ipairs(request) do
                c = c.nodes[s]
+               n = i
                if not c or c.leaf then
                        break
                end
@@ -138,6 +141,12 @@ function dispatch(request)
                end
        end
 
+       if c and c.leaf then
+               for j=n+1, #request do
+                       table.insert(args, request[j])
+               end
+       end
+
        if track.i18n then
                require("luci.i18n").loadc(track.i18n)
        end
@@ -190,7 +199,7 @@ function dispatch(request)
                        luci.util.updfenv(c.target, mod)
                end
                
-               stat, err = luci.util.copcall(c.target)
+               stat, err = luci.util.copcall(c.target, unpack(args))
                if not stat then
                        error500(err)
                end
@@ -201,7 +210,7 @@ end
 
 --- Generate the dispatching index using the best possible strategy.
 function createindex()
-       local path = luci.sys.libpath() .. "/controller/"
+       local path = luci.util.libpath() .. "/controller/"
        local suff = ".lua"
        
        if luci.util.copcall(require, "luci.fastindex") then
@@ -430,8 +439,8 @@ function cbi(model)
        require("luci.cbi")
        require("luci.template")
 
-       return function()
-               local stat, maps = luci.util.copcall(luci.cbi.load, model)
+       return function(...)
+               local stat, maps = luci.util.copcall(luci.cbi.load, model, ...)
                if not stat then
                        error500(maps)
                        return true