2 LuCI - UCI libuci wrapper
5 Wrapper for the libuci Lua bindings
11 Copyright 2008 Steven Barth <steven@midlink.org>
13 Licensed under the Apache License, Version 2.0 (the "License");
14 you may not use this file except in compliance with the License.
15 You may obtain a copy of the License at
17 http://www.apache.org/licenses/LICENSE-2.0
19 Unless required by applicable law or agreed to in writing, software
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
27 module("luci.model.uci.libuci", package.seeall)
34 Session = luci.util.class()
36 -- Session constructor
37 function Session.__init__(self, savedir)
38 self.savedir = savedir or luci.model.uci.savedir
39 uci.set_savedir(self.savedir)
42 function Session.add(self, config, section_type)
43 return uci.add(config, section_type)
46 function Session.changes(self, config)
48 return uci.changes(config)
54 function Session.commit(self, config)
55 return self:t_commit(config)
58 function Session.del(self, config, section, option)
59 return uci.del(config, section, option)
62 function Session.get(self, config, section, option)
63 return self:t_get(config, section, option)
66 function Session.revert(self, config)
67 return self:t_revert(config)
70 function Session.sections(self, config)
71 return self:t_sections(config)
74 function Session.set(self, config, section, option, value)
75 return self:t_set(config, section, option, value) and self:t_save(config)
78 function Session.synchronize(self)
79 return uci.set_savedir(self.savedir)
85 function Session.t_load(self, config)
86 return self:synchronize() and uci.load(config)
89 function Session.t_save(self, config)
90 return uci.save(config)
93 function Session.t_add(self, config, type)
94 return self:add(config, type)
97 function Session.t_commit(self, config)
98 return uci.commit(config)
101 function Session.t_del(self, config, section, option)
102 return self:del(config, section, option)
105 function Session.t_get(self, config, section, option)
107 return uci.get(config, section, option)
109 return uci.get(config, section)
113 function Session.t_revert(self, config)
114 return uci.revert(config)
117 function Session.t_sections(self, config)
118 return uci.get_all(config)
121 function Session.t_set(self, config, section, option, value)
123 return uci.set(config, section, option, value)
125 return uci.set(config, section, value)