From 976ed6816f1f2ea5d8ce6d7f9f971a9b987d231a Mon Sep 17 00:00:00 2001 From: SergBobrovsky Date: Tue, 5 Jan 2021 12:21:04 +0300 Subject: [PATCH 1/3] refactot Route.all_plugins() My code accurately reproduces original functional, but is it correct? In original code `unique` collects plugin names to avoid repeats. If plugin has no name, this check not. So, noname plugin can repeats. Is it right logic? --- bottle.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bottle.py b/bottle.py index 23fff762c..3441eb3f7 100755 --- a/bottle.py +++ b/bottle.py @@ -550,14 +550,14 @@ def prepare(self): def all_plugins(self): """ Yield all Plugins affecting this route. """ - unique = set() - for p in reversed(self.app.plugins + self.plugins): - if True in self.skiplist: break - name = getattr(p, 'name', False) - if name and (name in self.skiplist or name in unique): continue - if p in self.skiplist or type(p) in self.skiplist: continue - if name: unique.add(name) - yield p + if True in self.skiplist: return + skips = set(self.skiplist) + for plugins in self.plugins, self.app.plugins: + for p in reversed(plugins): + if p not in skips and type(p) not in skips: + name = getattr(p, 'name', False) + if name and name not in skips: skips.add(name) + yield p def _make_callback(self): callback = self.callback From d6690fff60604180e8cc2e818868ff0b983e5d07 Mon Sep 17 00:00:00 2001 From: SergBobrovsky Date: Tue, 5 Jan 2021 14:20:54 +0300 Subject: [PATCH 2/3] Update bottle.py --- bottle.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bottle.py b/bottle.py index 3441eb3f7..5f6f54e9b 100755 --- a/bottle.py +++ b/bottle.py @@ -552,11 +552,11 @@ def all_plugins(self): """ Yield all Plugins affecting this route. """ if True in self.skiplist: return skips = set(self.skiplist) - for plugins in self.plugins, self.app.plugins: - for p in reversed(plugins): - if p not in skips and type(p) not in skips: - name = getattr(p, 'name', False) - if name and name not in skips: skips.add(name) + for p in [*self.plugins[::-1], *self.app.plugins[::-1]]: + if p not in skips and type(p) not in skips: + name = getattr(p, 'name', False) + if not name or name and name not in skips: + skips.add(name) yield p def _make_callback(self): From 0457ab61acbbb23338b1fbad3db7ad30ef457b90 Mon Sep 17 00:00:00 2001 From: SergBobrovsky Date: Tue, 5 Jan 2021 22:23:46 +0300 Subject: [PATCH 3/3] Update bottle.py --- bottle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bottle.py b/bottle.py index 5f6f54e9b..b5aecba1f 100755 --- a/bottle.py +++ b/bottle.py @@ -552,7 +552,7 @@ def all_plugins(self): """ Yield all Plugins affecting this route. """ if True in self.skiplist: return skips = set(self.skiplist) - for p in [*self.plugins[::-1], *self.app.plugins[::-1]]: + for p in reversed(self.app.plugins + self.plugins): if p not in skips and type(p) not in skips: name = getattr(p, 'name', False) if not name or name and name not in skips: