luaopenwrtluci

Function in LuCI project


Here is a code block in LuCI (OpenWrt web UI) project.

I don't understand what this function is doing, and I am unable to find where it is called. Where is this function being called and what it is doing?

p = s:option(ListValue, "proto", translate("Protocol"))
p.override_values = true

p:value("pppoe", "PPPoE") 
p:value("pptp",  "PPTP")  

function p.write(self, section, value)
    if value == "pptp" or value == "pppoe" then
        self.map:set(section, "peerdns", "1")
        self.map:set(section, "defaultroute", "1")
    end
    return ListValue.write(self, section, value)
end

Solution

  • The function p.write(self, section, value) is overriding the abstract parent method. LuCI is an MVC, so Listvalue calls the write function when the page appling automatic.