[luci] LuCI cbi save/save&apply hook
Jo-Philipp Wich
xm at subsignal.org
Sat Sep 18 07:38:58 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi.
>> When writing my own custom cbi models, how can I hook the save/save&apply
>> button to copy the file that was just edited to another location (in
>> addition to being saved in /etc/config/whatever?
LuCI Trunk and the 0.9 branch offer hooks for that:
on_init | Before rendering the model
on_parse | Before reading any form values
on_before_commit | Before writing the config
on_after_commit | After writing the config
on_before_apply | Before restarting services
on_after_apply | After restarting services
on_cancel | When the form was cancelled
Use them like this:
- -- >8 --
m = Map("foo", ...)
m.on_after_commit = function(self)
-- all written config names are in self.parsechain
local file
for _, file in ipairs(self.parsechain) do
-- copy "file" ...
done
end
- -- 8< --
HTH, Jow
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyUUHIACgkQdputYINPTPP4TACeOfpFkK/9glrUVDOtkDjQeSMz
T7oAn0Trj4ljzjreVxZ9rxsGczmBexzE
=Pqo6
-----END PGP SIGNATURE-----
More information about the luci
mailing list