Software / code / prosody
Comparison
core/configmanager.lua @ 3515:bb494c3aa364
configmanager: Allow VirtualHost/Component definitions to be followed by a table of config options
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 08 Oct 2010 03:19:20 +0100 |
| parent | 3384:b7600dd7cd42 |
| child | 3573:f31fa6520a4b |
comparison
equal
deleted
inserted
replaced
| 3514:fdae08713c67 | 3515:bb494c3aa364 |
|---|---|
| 135 name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); | 135 name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0); |
| 136 end | 136 end |
| 137 rawset(env, "__currenthost", name); | 137 rawset(env, "__currenthost", name); |
| 138 -- Needs at least one setting to logically exist :) | 138 -- Needs at least one setting to logically exist :) |
| 139 set(name or "*", "core", "defined", true); | 139 set(name or "*", "core", "defined", true); |
| 140 return function (config_options) | |
| 141 rawset(env, "__currenthost", "*"); -- Return to global scope | |
| 142 for option_name, option_value in pairs(config_options) do | |
| 143 set(name or "*", "core", option_name, option_value); | |
| 144 end | |
| 145 end; | |
| 140 end | 146 end |
| 141 env.Host, env.host = env.VirtualHost, env.VirtualHost; | 147 env.Host, env.host = env.VirtualHost, env.VirtualHost; |
| 142 | 148 |
| 143 function env.Component(name) | 149 function env.Component(name) |
| 144 if rawget(config, name) and rawget(config[name].core, "defined") and not rawget(config[name].core, "component_module") then | 150 if rawget(config, name) and rawget(config[name].core, "defined") and not rawget(config[name].core, "component_module") then |
| 147 end | 153 end |
| 148 set(name, "core", "component_module", "component"); | 154 set(name, "core", "component_module", "component"); |
| 149 -- Don't load the global modules by default | 155 -- Don't load the global modules by default |
| 150 set(name, "core", "load_global_modules", false); | 156 set(name, "core", "load_global_modules", false); |
| 151 rawset(env, "__currenthost", name); | 157 rawset(env, "__currenthost", name); |
| 158 local function handle_config_options(config_options) | |
| 159 rawset(env, "__currenthost", "*"); -- Return to global scope | |
| 160 for option_name, option_value in pairs(config_options) do | |
| 161 set(name or "*", "core", option_name, option_value); | |
| 162 end | |
| 163 end | |
| 152 | 164 |
| 153 return function (module) | 165 return function (module) |
| 154 if type(module) == "string" then | 166 if type(module) == "string" then |
| 155 set(name, "core", "component_module", module); | 167 set(name, "core", "component_module", module); |
| 168 return handle_config_options; | |
| 156 end | 169 end |
| 170 return handle_config_options(module); | |
| 157 end | 171 end |
| 158 end | 172 end |
| 159 env.component = env.Component; | 173 env.component = env.Component; |
| 160 | 174 |
| 161 function env.Include(file) | 175 function env.Include(file) |