{"action":"created","issue":{"url":"https://api.github.com/repos/biosustain/potion/issues/41","labels_url":"https://api.github.com/repos/biosustain/potion/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/biosustain/potion/issues/41/comments","events_url":"https://api.github.com/repos/biosustain/potion/issues/41/events","html_url":"https://github.com/biosustain/potion/issues/41","id":111011870,"number":41,"title":"Allow disabling of base resource methods","user":{"login":"kolanos","id":17498,"avatar_url":"https://avatars.githubusercontent.com/u/17498?v=3","gravatar_id":"","url":"https://api.github.com/users/kolanos","html_url":"https://github.com/kolanos","followers_url":"https://api.github.com/users/kolanos/followers","following_url":"https://api.github.com/users/kolanos/following{/other_user}","gists_url":"https://api.github.com/users/kolanos/gists{/gist_id}","starred_url":"https://api.github.com/users/kolanos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolanos/subscriptions","organizations_url":"https://api.github.com/users/kolanos/orgs","repos_url":"https://api.github.com/users/kolanos/repos","events_url":"https://api.github.com/users/kolanos/events{/privacy}","received_events_url":"https://api.github.com/users/kolanos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-12T16:37:27Z","updated_at":"2015-10-19T15:38:03Z","closed_at":null,"body":"There may be a simple way to do this already, but I haven't come across it yet. But it would be useful to have a way to disable methods on a resource-by-resource basis. Specifically the ones that are provided by the ModelResource class.\r\n\r\nFor example...\r\n\r\n    class ReadOnlyResource(ModelResource):\r\n        class Meta:\r\n            methods = {\r\n                'create': False,\r\n                'update': False,\r\n                'destroy': False\r\n            }\r\n\r\n    class CreateOnlyResource(ModelResource):\r\n        class Meta:\r\n            methods = {\r\n                'create': True,\r\n                'read': False,\r\n                'update': False,\r\n                'destroy': False\r\n            }\r\n\r\nThen any method that is ``False`` returns a ``405``. Not sure if ``methods`` should default to ``True`` or ``False``, I would lean ``False`` but that would break from the current behavior of the base methods being accessible. Although defaulting to ``False`` would likely be a reduction in code for most situations, especially with inheritance. It would also be more Pythonic as making base methods available would be explicit instead of implicit."},"comment":{"url":"https://api.github.com/repos/biosustain/potion/issues/comments/149252079","html_url":"https://github.com/biosustain/potion/issues/41#issuecomment-149252079","issue_url":"https://api.github.com/repos/biosustain/potion/issues/41","id":149252079,"user":{"login":"lyschoening","id":74085,"avatar_url":"https://avatars.githubusercontent.com/u/74085?v=3","gravatar_id":"","url":"https://api.github.com/users/lyschoening","html_url":"https://github.com/lyschoening","followers_url":"https://api.github.com/users/lyschoening/followers","following_url":"https://api.github.com/users/lyschoening/following{/other_user}","gists_url":"https://api.github.com/users/lyschoening/gists{/gist_id}","starred_url":"https://api.github.com/users/lyschoening/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lyschoening/subscriptions","organizations_url":"https://api.github.com/users/lyschoening/orgs","repos_url":"https://api.github.com/users/lyschoening/repos","events_url":"https://api.github.com/users/lyschoening/events{/privacy}","received_events_url":"https://api.github.com/users/lyschoening/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T15:38:03Z","updated_at":"2015-10-19T15:38:03Z","body":"It is now possible in `master` to disable individual routes by setting `Meta.disabled_routes` to the relation names of the routes. These are inherited, but can be reset in later routes. The routes simply are not registered with Flask for the given resource, so the response code will be 404 or 405 depending on whether or not there is still another method registered at the url rule of the disabled route.\r\n\r\nI've also added the option to decorate individual routes via a `Meta.route_decorators` dictionary. This is more closely related to #36.\r\n\r\nFinally, it is now possible to override individual Route methods at a time by simply redefining them. Before it was only possible to override a method for a url rule by completely rewriting the route.\r\n\r\nWhat I still would like to do is reformat `principals` so it that it uses `Meta.disabled_routes` to disable any routes that are completely unavailable under a given permissions configuration. This will be part of the multi-backend refactor.\r\n\r\nLeaving this issue open until it is documented."}}