Add core.actions for managing server 'actions'; and make modulemanager register actio...
authorMatthew Wild <mwild1@gmail.com>
Mon, 12 Jan 2009 04:05:10 +0000 (04:05 +0000)
committerMatthew Wild <mwild1@gmail.com>
Mon, 12 Jan 2009 04:05:10 +0000 (04:05 +0000)
core/actions.lua [new file with mode: 0644]
core/modulemanager.lua

diff --git a/core/actions.lua b/core/actions.lua
new file mode 100644 (file)
index 0000000..d0be5ae
--- /dev/null
@@ -0,0 +1,19 @@
+\r
+local actions = {};\r
+\r
+function register(path, t)\r
+       local curr = actions;\r
+       for comp in path:gmatch("([^/]+)/") do\r
+               if curr[comp] == nil then\r
+                       curr[comp] = {};\r
+               end\r
+               curr = curr[comp];\r
+               if type(curr) ~= "table" then\r
+                       return nil, "path-taken";\r
+               end\r
+       end\r
+       curr[path:match("/([^/]+)$")] = t;\r
+       return true;\r
+end\r
+\r
+return { actions = actions, register= register };
\ No newline at end of file
index 3481aac68fc84a8aea60b71276e74413f9519c72..6ef39e82950661f63904589946628b2174e841e5 100644 (file)
@@ -27,7 +27,7 @@ local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler;
 local eventmanager = require "core.eventmanager";
 local config = require "core.configmanager";
 local multitable_new = require "util.multitable".new;
-
+local register_actions = require "core.actions".register;
 
 local loadfile, pcall = loadfile, pcall;
 local setmetatable, setfenv, getfenv = setmetatable, setfenv, getfenv;
@@ -254,4 +254,17 @@ end
 
 --------------------------------------------------------------------
 
+local actions = {};
+
+function actions.load(params)
+       --return true, "Module loaded ("..params.module.." on "..params.host..")";
+       return load(params.host, params.module);
+end
+
+function actions.unload(params)
+       return unload(params.host, params.module);
+end
+
+register_actions("/modules", actions);
+
 return _M;