From bd947a92895a9541aba910deebf2c277112d136c Mon Sep 17 00:00:00 2001 From: Simon Olofsson Date: Sun, 7 Jan 2024 22:13:13 +0100 Subject: [PATCH] #89 - Methods exposing a simple way to execute plugin methods in correct order --- pyttman/core/internals.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pyttman/core/internals.py b/pyttman/core/internals.py index f02b6d4..5d0597e 100644 --- a/pyttman/core/internals.py +++ b/pyttman/core/internals.py @@ -163,3 +163,17 @@ def abilities(self, abilities): for ability in abilities: setattr(self, ability.__class__.__name__, ability) self._abilities.add(ability) + + def execute_plugins_before_start(self): + try: + for plugin in self.plugins: + self.loaded_plugins.ingest(plugin) + plugin.before_app_start(self) + except Exception as e: + raise PyttmanPluginException( + f"The plugin '{plugin.__class__.__name__}' " + f"caused the boostrap to fail.") from e + + def execute_plugins_after_stop(self): + for plugin in self.plugins: + plugin.after_app_stops(self)