diff options
author | Steven Barth <steven@midlink.org> | 2008-08-26 23:00:44 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-26 23:00:44 +0000 |
commit | 91ba7c42f5b45614c9f4c803d09399f08a8e27b1 (patch) | |
tree | 21d1e1d67b3bee82eb123c0c5dbb274f2fcb6b59 /modules/admin-full | |
parent | 43b3217e5595acc91ff6d7614a5c21c88696fbcc (diff) |
UCI API changes
Diffstat (limited to 'modules/admin-full')
10 files changed, 35 insertions, 42 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua index 23a575852..f95b8324d 100644 --- a/modules/admin-full/luasrc/controller/admin/network.lua +++ b/modules/admin-full/luasrc/controller/admin/network.lua @@ -15,7 +15,7 @@ module("luci.controller.admin.network", package.seeall) function index() require("luci.i18n") - require("luci.model.uci") + local uci = require("luci.model.uci").cursor() local i18n = luci.i18n.translate local page = node("admin", "network") @@ -32,7 +32,7 @@ function index() page.target = form("admin_network/wireless") page.title = i18n("wifi") page.order = 15 - luci.model.uci.foreach("wireless", "wifi-device", + uci:foreach("wireless", "wifi-device", function (section) local ifc = section[".name"] entry({"admin", "network", "wireless", ifc}, @@ -49,7 +49,7 @@ function index() page.target = cbi("admin_network/network") page.title = i18n("interfaces", "Schnittstellen") page.order = 10 - luci.model.uci.foreach("network", "interface", + uci:foreach("network", "interface", function (section) local ifc = section[".name"] if ifc ~= "loopback" then diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index fdddf6b8d..6cf951a15 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -216,7 +216,7 @@ end function _keep_pattern() local kpattern = "" - local files = luci.model.uci.get_all("luci", "flash_keep") + local files = luci.model.uci.cursor():get_all("luci", "flash_keep") if files then kpattern = "" for k,v in pairs(files) do diff --git a/modules/admin-full/luasrc/controller/admin/uci.lua b/modules/admin-full/luasrc/controller/admin/uci.lua index 5dd0aaf6e..f5a45707c 100644 --- a/modules/admin-full/luasrc/controller/admin/uci.lua +++ b/modules/admin-full/luasrc/controller/admin/uci.lua @@ -48,7 +48,7 @@ function convert_changes(changes) end function action_changes() - local changes = convert_changes(luci.model.uci.changes()) + local changes = convert_changes(luci.model.uci.cursor():changes()) luci.template.render("admin_uci/changes", {changes=changes}) end @@ -56,6 +56,7 @@ function action_apply() local path = luci.dispatcher.context.path local changes = luci.model.uci.changes() local output = "" + local uci = luci.model.uci.cursor() if changes then local com = {} @@ -65,9 +66,9 @@ function action_apply() for r, tbl in pairs(changes) do if r then if path[#path] ~= "apply" then - luci.model.uci.load_config(r) - luci.model.uci.commit(r) - luci.model.uci.unload(r) + uci:load(r) + uci:commit(r) + uci:unload(r) end if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then run[luci.config.uci_oncommit[r]] = true @@ -87,15 +88,16 @@ end function action_revert() - local changes = luci.model.uci.changes() + local uci = luci.model.uci.cursor() + local changes = uci:changes() if changes then local revert = {} -- Collect files to be reverted for r, tbl in pairs(changes) do - luci.model.uci.load_config(r) - luci.model.uci.revert(r) - luci.model.uci.unload(r) + uci:load(r) + uci:revert(r) + uci:unload(r) end end diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua index af018eaa8..42b93b599 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcp.lua @@ -24,7 +24,8 @@ s.anonymous = true iface = s:option(ListValue, "interface", translate("interface")) luci.tools.webadmin.cbi_add_networks(iface) -luci.model.uci.foreach("network", "interface", +local uci = luci.model.uci.cursor() +uci:foreach("network", "interface", function (section) if section[".name"] ~= "loopback" then iface.default = iface.default or section[".name"] @@ -32,7 +33,7 @@ luci.model.uci.foreach("network", "interface", end end) -luci.model.uci.foreach("network", "alias", +uci:foreach("network", "alias", function (section) iface:value(section[".name"]) s:depends("interface", section[".name"]) diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua b/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua index 3c89de31d..0b2f55a31 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/dhcpleases.lua @@ -16,7 +16,7 @@ require("luci.tools.webadmin") m2 = Map("luci_ethers", translate("dhcp_leases")) local leasefn, leasefp, leases -luci.model.uci.foreach("dhcp", "dnsmasq", +luci.model.uci.cursor():foreach("dhcp", "dnsmasq", function(section) leasefn = section.leasefile end diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua index 716631232..5470b8a24 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/ifaces.lua @@ -49,8 +49,8 @@ if zones then fwzone.rmempty = true fwzone:value("", "- " .. translate("none") .. " -") fwzone:value(arg[1]) - luci.model.uci.load_config("firewall") - luci.model.uci.foreach("firewall", "zone", + m.uci:load("firewall") + m.uci:foreach("firewall", "zone", function (section) fwzone:value(section.name) end @@ -61,14 +61,14 @@ if zones then local stat if not zone then - stat = luci.model.uci.section("firewall", "zone", nil, { + stat = m.uci:section("firewall", "zone", nil, { name = value, network = section }) else - local net = luci.model.uci.get("firewall", zone, "network") + local net = m.uci:get("firewall", zone, "network") net = (net or value) .. " " .. section - stat = luci.model.uci.set("firewall", zone, "network", net) + stat = m.uci:set("firewall", zone, "network", net) end if stat then @@ -80,7 +80,7 @@ if zones then fwzone.value = table.concat(zones, ", ") end fwzone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones") - luci.model.uci.unload("firewall") + m.uci:unload("firewall") end ipaddr = s:option(Value, "ipaddr", translate("ipaddress")) diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua index 3924e7c6c..c32aea891 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua @@ -15,11 +15,7 @@ $Id$ require("luci.sys") require("luci.tools.webadmin") -luci.model.uci.load_state("network") -local netstate = luci.model.uci.get_all("network") -luci.model.uci.unload("network") - - +local netstate = luci.model.uci.cursor_state():get_all("network") m = Map("network", translate("interfaces")) local created @@ -70,7 +66,8 @@ end ifname.titleref = luci.dispatcher.build_url("admin", "network", "vlan") -if luci.model.uci.load("firewall") then + +if luci.model.uci.cursor():load("firewall") then zone = s:option(DummyValue, "_zone", translate("zone")) zone.titleref = luci.dispatcher.build_url("admin", "network", "firewall", "zones") diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua b/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua index d7b851968..aa32324e6 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/routes.lua @@ -48,11 +48,6 @@ s = m:section(TypedSection, "route", translate("a_n_routes_static")) s.addremove = true s.anonymous = true -function s.render(...) - luci.model.uci.load_config("network") - TypedSection.render(...) -end - s.template = "cbi/tblsection" iface = s:option(ListValue, "interface", translate("interface")) diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua index e53fb14fd..46f05a3af 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua @@ -86,12 +86,12 @@ network.combobox_manual = translate("a_w_netmanual") luci.tools.webadmin.cbi_add_networks(network) function network.write(self, section, value) - if not luci.model.uci.get("network", value) then + if not m:uci.get("network", value) then m:chain("network") - luci.model.uci.set("network", value, "interface") + m.uci:set("network", value, "interface") Value.write(self, section, value) else - if luci.model.uci.get("network", value) == "interface" then + if m.uci:get("network", value) == "interface" then Value.write(self, section, value) end end diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua index 4c7794db9..4f19f4e2c 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wireless.lua @@ -15,10 +15,7 @@ $Id$ require("luci.sys") require("luci.tools.webadmin") -luci.model.uci.load_state("wireless") -local wireless = luci.model.uci.get_all("wireless") -luci.model.uci.unload("wireless") - +local wireless = luci.model.uci.cursor_state():get_all("wireless") local wifidata = luci.sys.wifi.getiwconfig() local ifaces = {} @@ -123,9 +120,10 @@ for k, v in pairs(wireless) do end function create.write(self, section, value) - luci.model.uci.load_config("wireless") - luci.model.uci.section("wireless", "wifi-iface", nil, {device=value}) - luci.model.uci.save_config("wireless") + local uci = luci.model.uci.cursor() + uci:load("wireless") + uci:section("wireless", "wifi-iface", nil, {device=value}) + uci:save("wireless") luci.http.redirect(luci.http.getenv("REQUEST_URI") .. "/" .. value) end |