[kupfer] plugins: Add 'finalize_plugin' to the plugin API
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] plugins: Add 'finalize_plugin' to the plugin API
- Date: Sat, 19 Mar 2011 13:27:44 +0000 (UTC)
commit 8dbfb3f39719b3b646d1030ee3cd12f9bd154166
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Mar 19 14:27:28 2011 +0100
plugins: Add 'finalize_plugin' to the plugin API
finalize_plugin, if it exists, is called when the plugin is unloaded
(but at the moment, *not* at exit/quit).
kupfer/core/plugins.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/core/plugins.py b/kupfer/core/plugins.py
index e6cd508..199201d 100644
--- a/kupfer/core/plugins.py
+++ b/kupfer/core/plugins.py
@@ -12,7 +12,9 @@ content_decorators_attribute = "__kupfer_contents__"
action_decorators_attribute = "__kupfer_actions__"
action_generators_attribute = "__kupfer_action_generators__"
settings_attribute = "__kupfer_settings__"
+
initialize_attribute = "initialize_plugin"
+finalize_attribute = "finalize_plugin"
info_attributes = [
"__kupfer_name__",
@@ -375,6 +377,9 @@ def initialize_plugin(plugin_name):
initialize = get_plugin_attribute(plugin_name, initialize_attribute)
if initialize:
initialize(plugin_name)
+ finalize = get_plugin_attribute(plugin_name, finalize_attribute)
+ if finalize:
+ register_plugin_unimport_hook(plugin_name, finalize, plugin_name)
def unimport_plugin(plugin_name):
"""Remove @plugin_name from the plugin list and dereference its
@@ -386,7 +391,8 @@ def unimport_plugin(plugin_name):
for callback, args in reversed(_plugin_hooks[plugin_name]):
callback(*args)
except:
- prety.print_exc(__name__)
+ pretty.print_error(__name__, "Error finalizing", plugin_name)
+ pretty.print_exc(__name__)
del _plugin_hooks[plugin_name]
del _imported_plugins[plugin_name]
plugin_module_name = ".".join(_plugin_path(plugin_name))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]