From a36064641e6e86cbec49d67c615c6ba60cea4f4a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 17 Sep 2014 14:47:52 +0200 Subject: core.moduleapi: Use require instead of global to get storagemanager in module:open_store() --- core/moduleapi.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 8b477140..887ba858 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -19,6 +19,7 @@ local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; local error, setmetatable, type = error, setmetatable, type; local ipairs, pairs, select, unpack = ipairs, pairs, select, unpack; local tonumber, tostring = tonumber, tostring; +local require = require; local prosody = prosody; local hosts = prosody.hosts; @@ -366,7 +367,7 @@ function api:load_resource(path, mode) end function api:open_store(name, type) - return storagemanager.open(self.host, name or self.name, type); + return require"core.storagemanager".open(self.host, name or self.name, type); end return api; -- cgit v1.2.3 From 93a297bc8ffd909ff006d664e1e824d8a9307cba Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 17 Sep 2014 14:48:49 +0200 Subject: core.modulemanager, core.moduleapi: Hack around dependency loop --- core/moduleapi.lua | 7 +++++-- core/modulemanager.lua | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 887ba858..e5f86b37 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -7,7 +7,7 @@ -- local config = require "core.configmanager"; -local modulemanager = require "modulemanager"; -- This is necessary to avoid require loops +local modulemanager; -- This gets set from modulemanager local array = require "util.array"; local set = require "util.set"; local logger = require "util.logger"; @@ -370,4 +370,7 @@ function api:open_store(name, type) return require"core.storagemanager".open(self.host, name or self.name, type); end -return api; +return function (mm) + modulemanager = mm; + return api; +end diff --git a/core/modulemanager.lua b/core/modulemanager.lua index db4c6bd0..198e208a 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -37,7 +37,7 @@ local _G = _G; module "modulemanager" -local api = _G.require "core.moduleapi"; -- Module API container +local api = _G.require "core.moduleapi"(_M); -- Module API container -- [host] = { [module] = module_env } local modulemap = { ["*"] = {} }; -- cgit v1.2.3