Commit 36a4fe6c authored by Ted Trask's avatar Ted Trask

Remove all calls to 'module' in preparation for move to Lua 5.2

Use mymodule parameter for module definition.
This was also helpful in revealing places where the code relied on the global environment.
parent 58b3dd5c
module(..., package.seeall) local mymodule = {}
mvc = {} -- Use on_load function to handle multiple instances of this ACF (i.e. postgresql2)
mvc.on_load = function(self, parent) mymodule.mvc = {}
mymodule.mvc.on_load = function(self, parent)
self.model.set_processname(string.match(self.conf.prefix, "[^/]+")) self.model.set_processname(string.match(self.conf.prefix, "[^/]+"))
end end
default_action = "status" mymodule.default_action = "status"
function status(self) function mymodule.status(self)
return self.model.getstatus() return self.model.getstatus()
end end
function startstop(self) function mymodule.startstop(self)
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata) return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end end
function details(self) function mymodule.details(self)
return self.model.getstatusdetails() return self.model.getstatusdetails()
end end
function listfiles(self) function mymodule.listfiles(self)
return self.model.getfilelist() return self.model.getfilelist()
end end
function expert(self) function mymodule.expert(self)
return self.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit Postgresql File", "File Saved") return self.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit Postgresql File", "File Saved")
end end
return mymodule
module(..., package.seeall) local mymodule = {}
-- Load libraries -- Load libraries
modelfunctions = require("modelfunctions") modelfunctions = require("modelfunctions")
...@@ -15,7 +15,7 @@ local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin ...@@ -15,7 +15,7 @@ local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
local datadirectory local datadirectory
local filelist local filelist
function set_processname(p) function mymodule.set_processname(p)
processname = p processname = p
confdfile = "/etc/conf.d/"..processname confdfile = "/etc/conf.d/"..processname
end end
...@@ -34,23 +34,23 @@ end ...@@ -34,23 +34,23 @@ end
-- ################################################################################ -- ################################################################################
-- PUBLIC FUNCTIONS -- PUBLIC FUNCTIONS
function get_startstop(self, clientdata) function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(processname) return modelfunctions.get_startstop(processname)
end end
function startstop_service(self, startstop, action) function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action) return modelfunctions.startstop_service(startstop, action)
end end
function getstatus() function mymodule.getstatus()
return modelfunctions.getstatus(processname, packagename, "Postgresql Status") return modelfunctions.getstatus(processname, packagename, "Postgresql Status")
end end
function getstatusdetails() function mymodule.getstatusdetails()
return cfe({ type="longtext", value="", label="Postgresql Status Details" }) return cfe({ type="longtext", value="", label="Postgresql Status Details" })
end end
function getfilelist() function mymodule.getfilelist()
local listed_files = {} local listed_files = {}
for i,name in ipairs(determinefilelist()) do for i,name in ipairs(determinefilelist()) do
...@@ -63,10 +63,12 @@ function getfilelist() ...@@ -63,10 +63,12 @@ function getfilelist()
return cfe({ type="list", value=listed_files, label="Postgresql File List" }) return cfe({ type="list", value=listed_files, label="Postgresql File List" })
end end
function getfiledetails(filename) function mymodule.getfiledetails(filename)
return modelfunctions.getfiledetails(filename, determinefilelist()) return modelfunctions.getfiledetails(filename, determinefilelist())
end end
function updatefiledetails(self, filedetails) function mymodule.updatefiledetails(self, filedetails)
return modelfunctions.setfiledetails(self, filedetails, determinefilelist()) return modelfunctions.setfiledetails(self, filedetails, determinefilelist())
end end
return mymodule
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment