Software /
code /
prosody
Diff
core/configmanager.lua @ 754:01abf314fac0
Automated merge with http://waqas.ath.cx:8000/
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 29 Jan 2009 17:54:37 +0000 |
parent | 750:fbfcf8c1c830 |
child | 758:b1885732e979 |
line wrap: on
line diff
--- a/core/configmanager.lua Thu Jan 29 22:37:25 2009 +0500 +++ b/core/configmanager.lua Thu Jan 29 17:54:37 2009 +0000 @@ -107,7 +107,8 @@ parsers.lua = {}; function parsers.lua.load(data) local env; - env = setmetatable({ Host = true; host = true; }, { __index = function (t, k) + -- The ' = true' are needed so as not to set off __newindex when we assign the functions below + env = setmetatable({ Host = true; host = true; Component = true, component = true }, { __index = function (t, k) return rawget(_G, k) or function (settings_table) config[__currenthost or "*"][k] = settings_table; @@ -119,10 +120,21 @@ function env.Host(name) rawset(env, "__currenthost", name); + -- Needs at least one setting to logically exist :) set(name or "*", "core", "defined", true); end env.host = env.Host; + function env.Component(name) + return function (module) + set(name, "core", "component_module", module); + -- Don't load the global modules by default + set(name, "core", "modules_enable", false); + rawset(env, "__currenthost", name); + end + end + env.component = env.Component; + local chunk, err = loadstring(data); if not chunk then