Added virtual functions for enable()/disable() lifecycle management

pull/1653/head
tenchirocom 2025-04-15 21:54:30 +09:00
rodzic 78da2a619f
commit fec9437f2d
1 zmienionych plików z 22 dodań i 1 usunięć

Wyświetl plik

@ -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 WebODMs 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())
return "[{}]".format(self.get_module_name())