-
Notifications
You must be signed in to change notification settings - Fork 2k
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
update actions to use correct names #786
Conversation
Hi @tobes, Cool! It's about time to start removing references to package 👍 I know this is still WIP, but just to add my 2 cents... What do you think about renaming the methods from package_* to dataset_* first? Then, you'd just need to call Also, while you're at it, it would be great to refactor |
@vitorbaptista the thing is that extensions can override the actions/auth functions so we do need to do it at least for those. Also doing it this way allows the renaming to be done at our leisure. We probably should do that but it doesn't strictly need to be part of this branch to get the feature working. Also I suspect that some tests do nasty direct use of the functions so it may be more work even if needed. |
@vitorbaptista and yes there is refactoring that could be done but sometimes these things need to wait and also it is good to keep these changes separated. |
@tobes You mean that some extension might create a if _actions:
cleaned_action = new_authz.clean_action_name(action)
action_method = _actions.get(action) or _actions.get(cleaned_action)
if not action_method:
raise KeyError("Action '%s' not found" % action)
return action_method This could be extracted in a method and used by both I usually prefer to sneak refactorings inside normal cards, leaving pure refactoring cards just for big stuff. But I agree with you, this might be big. The main thing I would like to avoid is to call |
There's a tidier way of having a fallback key in a hash, if the first one doesn't exist, used in https://github.com/okfn/ckan/blob/master/ckan/lib/search/query.py#L337 query['facet.limit'] = query.get('facet.limit', config.get('search.facets.limit', '50')) I prefer the first one that I suggested though, as it's more explicit. |
No I mean we have |
This line is horrible on many levels and is the sort of code I try to kill :) mainly the default value should not be here and also I think we should do the config stuff differently but lets not discuss this here. Also |
update actions to use correct names
eg
package_show
should bedataset_show
we need to ensure that the old names continue to work etc - probably best to patch this via get_action - need to ensure that auth functions also behave the same way.