-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Misleading docstring in RequestHandler.prepare() #3430
Comments
It's true that the docs don't match the behavior here, but it's also worth looking at whether the current behavior is what we want. Why exactly was this an issue for you? Was it because your There are some exceptions to that rule today. SUPPORTED_METHODS is one, but errors from decode_argument and check_xsrf_cookie do the same thing. (and in the other direction, the fact that some errors call on_connection_close instead of on_finish can be confusing). Other errors short-circuit the process earlier, often in subtle ways: decoding the URL query string happens in two phases (first as bytes, and then as characters), and an error in the second phase will call So some things we could do are:
My inclination is to not provide too many specifics about prepare and errors, and to only call on_finish (and on_connection_close) if prepare was called, but I'd like to hear more about what kind of problem you encountered that prompted this issue. |
Hello @bdarnell, thank you for prompt reply.
yes , precisely that. I have some additional metrics setup in The code I work on has been written a while ago and changed by a number of people along the way and as a result the OO structure / inheritance of handlers is in a bad shape. Occasionally I need to restrict access to request methods in a child Handler. It's convenient to use
I agree, documenting all the side effects is just impossible...
sure, it makes no sense
I know that I have code that really on Another option could be to remove Thanks a lot for the clarification and all of your work on tornado! |
OK. Cleanup from
Our most complete documentation on this is at https://www.tornadoweb.org/en/stable/guide/structure.html#overriding-requesthandler-methods, which is probably not the best location, and it's also incomplete (this is what #2711 is about). But I think the best approach is to ensure that this page is complete and increase its visibility with links from all the relevant methods. |
ok, thanks again for the clarification. |
I think
RequestHandler.prepare()
docstring is misleading because it doesn't mention that the method has to be inSUPPORTED_METHODS
- otherwiseprepare()
won't be called.I suggest we change:
to:
The text was updated successfully, but these errors were encountered: