From fec9437f2de8115360ad87cf78f87996b5f14a67 Mon Sep 17 00:00:00 2001 From: tenchirocom Date: Tue, 15 Apr 2025 21:54:30 +0900 Subject: [PATCH] Added virtual functions for enable()/disable() lifecycle management --- app/plugins/plugin_base.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/plugins/plugin_base.py b/app/plugins/plugin_base.py index 9b1ef035..ba7afae4 100644 --- a/app/plugins/plugin_base.py +++ b/app/plugins/plugin_base.py @@ -57,6 +57,27 @@ class PluginBase(ABC): else: logger.warning("Failed to install requirements.txt for {}".format(self)) + def enable(self): + """ + Should be overriden by plugins to perform persistent setup and configuration + (e.g., registering static files, initializing databse entries, or hooking + into WebODM’s functionality). Called once, each time a plugin is enabled. If + this method throws an exception, it will not be enabled by the system. + :return: none + """ + pass + + def disable(self): + """ + Should be overriden by plugins to perform cleanup or other persistent tasks + to restore the system to pre-enabled state (e.g., removing hooks, deleting + temporary data, or restoring system state). Called once each time a plugin + is disabled. If this method fails to complete or throws an exception, it will + still be disabled by the system. + :return: none + """ + pass + def get_persistent_path(self, *paths): return get_plugins_persistent_path(self.name, *paths) @@ -247,4 +268,4 @@ class PluginBase(ABC): return self.manifest def __str__(self): - return "[{}]".format(self.get_module_name()) \ No newline at end of file + return "[{}]".format(self.get_module_name())