# HG changeset patch # User Matthew Wild # Date 1231733110 0 # Node ID d8a678e40a0a6c483e4adfabfcf5b61a8c5604a0 # Parent 8ddc85fa76027e89cee3e49c2b911e69a7c63bcc Add core.actions for managing server 'actions'; and make modulemanager register actions 'load' and 'unload' diff -r 8ddc85fa7602 -r d8a678e40a0a core/actions.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/actions.lua Mon Jan 12 04:05:10 2009 +0000 @@ -0,0 +1,19 @@ + +local actions = {}; + +function register(path, t) + local curr = actions; + for comp in path:gmatch("([^/]+)/") do + if curr[comp] == nil then + curr[comp] = {}; + end + curr = curr[comp]; + if type(curr) ~= "table" then + return nil, "path-taken"; + end + end + curr[path:match("/([^/]+)$")] = t; + return true; +end + +return { actions = actions, register= register }; \ No newline at end of file diff -r 8ddc85fa7602 -r d8a678e40a0a core/modulemanager.lua --- a/core/modulemanager.lua Mon Jan 12 04:02:29 2009 +0000 +++ b/core/modulemanager.lua Mon Jan 12 04:05:10 2009 +0000 @@ -27,7 +27,7 @@ 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 @@ -------------------------------------------------------------------- +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;