libs: remove http folder
[project/luci.git] / libs / uci / luasrc / model / uci / bind.lua
index 89ad328..9472dab 100644 (file)
@@ -45,6 +45,10 @@ function bind.section(self, stype)
                inst.bind  = self
                inst.stype = stype
                inst.sid   = sid
+
+               if inst._init then
+                       inst:_init(sid)
+               end
        end
        return x
 end
@@ -126,7 +130,11 @@ end
 function bsection.set(self, k, v, c)
        local stat
        if type(c) == "string" then
-               stat = self:uciop("set", c, k, v)
+               if type(v) == "table" and #v == 0 then
+                       stat = self:uciop("delete", c, k)
+               else
+                       stat = self:uciop("set", c, k, v)
+               end
        else
                self:uciop("foreach", self.stype,
                        function(s)
@@ -156,9 +164,9 @@ end
 function bsection.property_bool(self, k, n)
        self[n or k] = function(c, val)
                if val == nil then
-                       return self.bind:bool(c:get(k, c.sid))
+                       return bind:bool(c:get(k, c.sid))
                else
-                       return c:set(k, self.bind:bool(val) and "1" or "0", c.sid)
+                       return c:set(k, bind:bool(val) and "1" or "0", c.sid)
                end
        end
 end