[kupfer] core: Dereference plugin's submodules as plugin unload



commit 60239d8d52da1d33df3af60e963e5b960c083346
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Mar 2 23:15:16 2011 +0100

    core: Dereference plugin's submodules as plugin unload
    
    We dereference (no real unload of python modules) the modules of
    plugins when we unload them. For packages with submodules we need to
    unload these too.
    
    Launchpad-bug: https://bugs.launchpad.net/kupfer/+bug/694061

 kupfer/core/plugins.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/core/plugins.py b/kupfer/core/plugins.py
index 7470862..ef85149 100644
--- a/kupfer/core/plugins.py
+++ b/kupfer/core/plugins.py
@@ -368,8 +368,17 @@ def initialize_plugin(plugin_name):
 	settings_dict.initialize(plugin_name)
 
 def unimport_plugin(plugin_name):
+	"""Remove @plugin_name from the plugin list and dereference its
+	python modules.
+	"""
 	del _imported_plugins[plugin_name]
-	sys.modules.pop(".".join(_plugin_path(plugin_name)))
+	plugin_module_name = ".".join(_plugin_path(plugin_name))
+	pretty.print_debug(__name__, "Dereferencing module", plugin_module_name)
+	sys.modules.pop(plugin_module_name)
+	for mod in list(sys.modules):
+		if mod.startswith(plugin_module_name + "."):
+			pretty.print_debug(__name__, "Dereferencing module", mod)
+			sys.modules.pop(mod)
 
 def get_plugin_error(plugin_name):
 	"""



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]