diff --git a/shopdb/plugins/__init__.py b/shopdb/plugins/__init__.py index cf432c7..9b1d74e 100644 --- a/shopdb/plugins/__init__.py +++ b/shopdb/plugins/__init__.py @@ -257,11 +257,16 @@ class PluginManager: self.registry.enable(name) - # Load the plugin - plugin = self.loader.load_plugin(name, self._app, self._db) - if plugin: - self._register_plugin_components(plugin) - plugin.on_enable(self._app) + # Fire the on_enable hook best-effort. Do NOT register the blueprint + # here: Flask forbids register_blueprint after the first request, so + # routes/nav for a re-enabled plugin take effect on the next restart + # (symmetric with disable). + try: + plugin = self.loader.load_plugin(name, self._app, self._db) + if plugin: + plugin.on_enable(self._app) + except Exception: + logger.exception(f"on_enable hook failed for plugin {name}") logger.info(f"Enabled plugin: {name}") return True