h.remove_url_param fail with minimal set of params#6414
Merged
Conversation
6771206 to
5c0bd2d
Compare
5 tasks
Contributor
|
Will this be backported to CKAN 2.9? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
h.remove_url_paramwith the minimal set of parameters:will throw an error on the
organization.readpage(not only here). Because internally it gets current blueprint and view (g.controllerandg.action) and tries to build the URLh.url_for(blueprint + "." + view). And as long as the given blueprint requires extra arguments (package_typefor dataset pages,group_type/is_organizationfor group pages,idfor organization.read page, etc), this will fail. User has to do something likeWhile it is perfectly ok from the clarity point of view, it requires every developer to know CKAN internals and these extra parameters. And it makes the given helper too fragile. In addition, the
extrasparameter is optional, so there may be some expectations, likewhenever I'm using
h.remove_url_param("q")in the simplest form, I expectqto be removed from the CURRENT URL, whatever it isThis PR takes all the extra parameters required to build the current URL and adds them only when neither
controllernoractionnorextrasargument is present. I.e, only when the user trying to modify the current URL.PS. And it also updates
toolkit.get_endpoint. Now it won't raise RuntimeError in CLI. Instead, its returnsNone, None, which is quite safe, I think.