Fix internal error when enabling a plugin
enable_plugin called register_blueprint at runtime, which Flask forbids after the first request (AssertionError -> 500). Enabling now flips the registry flag and fires on_enable best-effort; routes register on the next restart, symmetric with disable. Nav reflects the re-enable immediately. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user