* libs/uci: Fixed uci.delete_all
authorSteven Barth <steven@midlink.org>
Sat, 7 Jun 2008 07:58:35 +0000 (07:58 +0000)
committerSteven Barth <steven@midlink.org>
Sat, 7 Jun 2008 07:58:35 +0000 (07:58 +0000)
* Fixed Freifunk wizard

applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua
libs/uci/luasrc/model/uci.lua

index 84a22238ea270decfde835cba43610c2919c538f..8a01f055c6f23a7ead31bd843602a14f86a32a7d 100644 (file)
@@ -195,29 +195,29 @@ function configure_freifunk()
                        function (section)
                                local device = section[".name"]
                                
-                               if luci.http.formvalue("wifi."..iface) then
+                               if luci.http.formvalue("wifi."..device) then
                                        uci.delete_all("wireless", "wifi-iface",
                                                function (section)
                                                        return (section.device == device)
                                                end)
-                               end
-                               
-                               uci.tset("wireless", device, {
-                                       disabled = "0",
-                                       mode = "11g",
-                                       txantenna = "1",
-                                       rxantenna = "1",
-                                       channel = uci.get("freifunk", "community", "channel")
-                               })
                                
-                               uci.section("wireless", "wifi-iface", nil, {
-                                       device = iface,
-                                       network = "ff",
-                                       mode = "adhoc",
-                                       ssid = uci.get("freifunk", "community", "essid"),
-                                       bssid = uci.get("freifunk", "community", "bssid"),
-                                       txpower = 13
-                               })
+                                       uci.tset("wireless", device, {
+                                               disabled = "0",
+                                               mode = "11g",
+                                               txantenna = "1",
+                                               rxantenna = "1",
+                                               channel = uci.get("freifunk", "community", "channel")
+                                       })
+                                       
+                                       uci.section("wireless", "wifi-iface", nil, {
+                                               device = device,
+                                               network = "ff",
+                                               mode = "adhoc",
+                                               ssid = uci.get("freifunk", "community", "essid"),
+                                               bssid = uci.get("freifunk", "community", "bssid"),
+                                               txpower = 13
+                                       })
+                               end
                        end)
        end
 
index 20bc0495c2c26310fa97194133efecc7ca601dc5..bd6aba41a4252b54367e7b825ee18418b400d219 100644 (file)
@@ -27,6 +27,7 @@ local uci  = require("uci")
 local util = require("luci.util")
 local setmetatable, rawget, rawset = setmetatable, rawget, rawset
 local error, pairs, ipairs, tostring = error, pairs, ipairs, tostring
+local table, print = table, print
 
 module("luci.model.uci", function(m) setmetatable(m, {__index = uci}) end)
 
@@ -37,16 +38,16 @@ savedir_state = "/var/state"
 
 function delete_all(config, type, comparator)
        local del = {}
-       
-       foreach(config, type,
-               function (section)
+       local function helper (section)
                        if not comparator or comparator(section) then
                                table.insert(del, section[".name"])
                        end
-               end)
-               
+       end
+       
+       foreach(config, type, helper)
+       
        for i, j in ipairs(del) do
-               uci.delete(config, j)
+               delete(config, j)
        end
 end