From b7fdc82d303989b52b94ad496d5fcfcd2c21e9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 25 Feb 2020 15:35:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20buggy=20implementation=20o?= =?UTF-8?q?f=20(before|after)=5Frequest=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/server/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 3983909f4..b5433da1a 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -1353,7 +1353,8 @@ class Server(object): before_hooks = octoprint.plugin.plugin_manager().get_hooks("octoprint.server.api.before_request") after_hooks = octoprint.plugin.plugin_manager().get_hooks("octoprint.server.api.after_request") - for plugin, hook in before_hooks.items(): + for name, hook in before_hooks.items(): + plugin = octoprint.plugin.plugin_manager().get_plugin(name) for blueprint in blueprints: try: result = hook(plugin=plugin) @@ -1362,9 +1363,10 @@ class Server(object): blueprint.before_request(h) except Exception: self._logger.exception("Error processing before_request hooks from plugin {}".format(plugin), - extra=dict(plugin=plugin)) + extra=dict(plugin=name)) - for plugin, hook in after_hooks.items(): + for name, hook in after_hooks.items(): + plugin = octoprint.plugin.plugin_manager().get_plugin(name) for blueprint in blueprints: try: result = hook(plugin=plugin) @@ -1373,7 +1375,7 @@ class Server(object): blueprint.after_request(h) except Exception: self._logger.exception("Error processing after_request hooks from plugin {}".format(plugin), - extra=dict(plugin=plugin)) + extra=dict(plugin=name)) def _setup_mimetypes(self): # Safety measures for Windows... apparently the mimetypes module takes its translation from the windows