Modpython: MCString as a normal dict-like object.

See github issue #93
This commit is contained in:
Alexey Sokolov
2012-07-28 02:56:00 +07:00
parent 219e6a97ce
commit ac1b183583
3 changed files with 14 additions and 10 deletions
+9 -6
View File
@@ -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