-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactot Route.all_plugins() #1306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared to the original code I find this much harder to understand.
normally a
forloop in python is in the form:You wrote for
pluginsin<other list of plugins>. I didn't dive into analyzing in depth to see what is the other set of plugins. But this form offorwill immediately cause a headache for a lot of people.Further, an embedded for loop is harder to understand compared to a simple for loop.