-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[20.12LTS] Remove prefix from websocket handler name #2021
[20.12LTS] Remove prefix from websocket handler name #2021
Conversation
Codecov Report
@@ Coverage Diff @@
## 20.12LTS #2021 +/- ##
==============================================
- Coverage 92.796% 92.778% -0.017%
==============================================
Files 29 29
Lines 3262 3268 +6
Branches 571 573 +2
==============================================
+ Hits 3027 3032 +5
Misses 159 159
- Partials 76 77 +1
Continue to review full report at Codecov.
|
During reading the source code. I've found inconsistent behaviors among route storing of normal http handler and websocket, static file handlers. Firstly, the ways used to indicate a websocket handler and static file handler are different.
Secondly, the ways to pass blueprint names of http handler, websocket handler, static file handler, to be used in Formerly, only For blueprint websocket handler ( |
The new branch I am working on does not use any special prefixes for static or websockets. Also, there is a change to how routes are named in general. But I'll leave rhat discussion for #2010. |
Since we are merging this into the LTS, I am hesitant to cause breaking changes. While I agree there is the issue with I think the solution of removing the prefix does not consider a broader set of use cases. |
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.
Needs to handle fetching routes with and without so that it is not a breaking change.
@laggardkernel are you able to implement @ahoplins request? |
72723f8
to
68fa301
Compare
@sjsadowski Just pushed an update with backward support, in case anyone find the bug and uses |
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.
Looks great @laggardkernel. Can you add a test case to test_url_building.py
for both cases?
Something like this. Also, one for Blueprints.
def test_url_for_with_websocket_handlers(app):
@app.websocket("/ws")
async def my_handler(...):
...
assert app.url_for("my_handler") = "..."
assert app.url_for("websocket_handler_my_handler") = "..."
68fa301
to
d7ef280
Compare
@ahopkins Thanks for pointing out the correct place to add the test. I've updated and squashed the commits. |
Approved and will merge when Travis is done 🐢 I'll get this pushed out to the LTS tonight. |
Thanks again for this. |
@laggardkernel Can you address the CI issues? Linting issues can be fixed by running:
|
Remove the websocket prefix "websocket_handler_" introduced in 761eef7. Add a backward support for url_for() calling with this prefix in param "view_name".
d7ef280
to
a7521f6
Compare
@ahopkins Sorry, fixed and passed the CI. |
Formerly try to open for master branch GH-2020. Cause the Router is overhauled on master, open this pr for 20.12LTS.
Remove the websocket prefix
websocket_handler_
introduced in761eef7. Makes
url_for()
unable to find the corresponding ws route for non-bp websocket view.The key for the above handler used in
Router.route_names
iswebsocket_handler_websocket
, notwebsocket
. Removing thewebsocket_handler_
prefix fixes this bug. Searching in the source code, this very prefix is not used in anywhere.I guess the contributor of commit 761eef7 tried to mimic the registration behavior of static file handler, which prepend the handler name with prefix
_static_
, in order to store static file handler separately inRouter.routes_static_files
, not inRouter.routes_names
.