diff --git a/modules/modpython.cpp b/modules/modpython.cpp index 1fc63257..71169d12 100644 --- a/modules/modpython.cpp +++ b/modules/modpython.cpp @@ -202,7 +202,7 @@ public: } if (!PyObject_IsTrue(pyRes)) { // python module, but not handled by modpython itself. - // some module-loader written on python loaded it? + // some module-provider written on python loaded it? return CONTINUE; } Py_CLEAR(pyFunc); diff --git a/modules/modpython/modpython.i b/modules/modpython/modpython.i index 73e83996..aa2d449c 100644 --- a/modules/modpython/modpython.i +++ b/modules/modpython/modpython.i @@ -67,6 +67,9 @@ using std::allocator; %template(SModInfo) std::set; %template(SCString) std::set; typedef std::set SCString; +%template(MPyCString) std::map; +class MCString : public std::map {}; +%template(PyModules) std::vector; %typemap(in) CString& { String* p; @@ -171,9 +174,6 @@ class CPyRetBool { } %extend CModules { - void push_back(CModule* p) { - $self->push_back(p); - } bool removeModule(CModule* p) { for (CModules::iterator i = $self->begin(); $self->end() != i; ++i) { if (*i == p) { @@ -257,6 +257,7 @@ typedef std::vector > VPair; %extend CTemplate { void set(const CString& key, const CString& value) { + DEBUG("WARNING: modpython's CTemplate.set is deprecated and will be removed. Use normal dict's operations like Tmpl['foo'] = 'bar'"); (*$self)[key] = value; } } diff --git a/modules/modpython/znc.py b/modules/modpython/znc.py index 86930f49..ff8e6936 100644 --- a/modules/modpython/znc.py +++ b/modules/modpython/znc.py @@ -498,20 +498,22 @@ def load_module(modname, args, module_type, user, network, retmsg, modpython): retmsg.s = "Module [{}] is UserModule and needs user.".format(modname) unload_module(module) return 1 - user.GetModules().push_back(module._cmod) + cont = user elif module_type == CModInfo.NetworkModule: if not network: retmsg.s = "Module [{}] is Network module and needs a network.".format(modname) unload_module(module) return 1 - network.GetModules().push_back(module._cmod) + cont = network elif module_type == CModInfo.GlobalModule: - CZNC.Get().GetModules().push_back(module._cmod) + cont = CZNC.Get() else: retmsg.s = "Module [{}] doesn't support that module type.".format(modname) unload_module(module) return 1 + cont.GetModules().append(module._cmod) + try: loaded = True if not module.OnLoad(args, retmsg): @@ -555,11 +557,12 @@ def unload_module(module): _py_modules.discard(module) cmod = module._cmod if module.GetType() == CModInfo.UserModule: - cmod.GetUser().GetModules().removeModule(cmod) + cont = cmod.GetUser() elif module.GetType() == CModInfo.NetworkModule: - cmod.GetNetwork().GetModules().removeModule(cmod) + cont = cmod.GetNetwork() elif module.GetType() == CModInfo.GlobalModule: - CZNC.Get().GetModules().removeModule(cmod) + cont = CZNC.Get() + cont.GetModules().removeModule(cmod) del module._cmod cmod.DeletePyModule() del cmod