modulemanager: Set module.environment before calling add_host, otherwise the module will get the parent's environment (thanks xnyhps and Maranda)
--- a/core/modulemanager.lua Fri Apr 27 20:01:21 2012 +0100
+++ b/core/modulemanager.lua Fri Apr 27 21:37:45 2012 +0100
@@ -142,10 +142,10 @@
},{
__index = modulemap["*"][module_name].module;
});
+ local host_module = setmetatable({ module = host_module_api }, { __index = mod });
+ host_module_api.environment = host_module;
local ok, result, module_err = call_module_method(mod, "add_host", host_module_api);
if not ok or result == false then return nil, ok and module_err or result; end
- local host_module = setmetatable({ module = host_module_api }, { __index = mod });
- host_module.module.environment = host_module;
modulemap[host][module_name] = host_module;
return host_module;
end