-
-
Notifications
You must be signed in to change notification settings - Fork 91
[14.0][IMP] endpoint: support usage of querystring parameters #80
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: 14.0
Are you sure you want to change the base?
Conversation
|
Hi @simahawk, |
|
Review is appreciated but please don't merge yet, there might be a few changes. |
d1bff46 to
3532d63
Compare
|
Ready for review. |
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.
Thank you! Something I was thinking about since a while ;)
Just 1 remark about the naming: I prefer to make explicit everywhere down the stack, as params is quite an abused term 😉
Also, would be nice to see a test.
| * Response | ||
| * werkzeug | ||
| * exceptions | ||
| * params |
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.
| * params | |
| * querystring_params |
| ) | ||
|
|
||
| def _handle_exec__code(self, request): | ||
| def _handle_exec__code(self, request, params=None): |
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.
| def _handle_exec__code(self, request, params=None): | |
| def _handle_exec__code(self, request, querystring_params=None): |
| raise NotFound() | ||
| endpoint._validate_request(request) | ||
| result = endpoint._handle_request(request) | ||
| result = endpoint._handle_request(request, params=params) |
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.
| result = endpoint._handle_request(request, params=params) | |
| result = endpoint._handle_request(request, querystring_params=params) |
| if not self._code_snippet_valued(): | ||
| return {} | ||
| eval_ctx = self._get_code_snippet_eval_context(request) | ||
| eval_ctx["params"] = params or {} |
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.
| eval_ctx["params"] = params or {} | |
| eval_ctx["querystring_params"] = querystring_params or {} |
| ) | ||
|
|
||
| def _handle_request(self, request): | ||
| def _handle_request(self, request, params=None): |
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.
| def _handle_request(self, request, params=None): | |
| def _handle_request(self, request, querystring_params=None): |
| handler = self_with_user._get_handler() | ||
| try: | ||
| res = handler(request) | ||
| # In case the handler does not support params |
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.
I doubt we have any other handler ATM but just in case... ok, let's keep this but I would add a separated commit for backward compat that we can easily drop on migration.
Something like:
[imp] endpoint: support querystring params
[imp] endpoint: backward compat for querystring params
Old handlers might not accept this new kw args
Trash this commit in future versions. Eg: v18.
| if params: | ||
| res = handler(request, params=params) |
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.
| if params: | |
| res = handler(request, params=params) | |
| if querystring_params: | |
| res = handler(request, querystring_params=querystring_params) |
3532d63 to
f002179
Compare
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
No description provided.