Software /
code /
prosody
Diff
core/modulemanager.lua @ 4728:7c81b04a4fed
modulemanager: Set module.environment before calling add_host, otherwise the module will get the parent's environment (thanks xnyhps and Maranda)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 27 Apr 2012 21:37:45 +0100 |
parent | 4665:6be91ca54613 |
child | 4733:791388f90156 |
line wrap: on
line diff
--- 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