{"action":"created","issue":{"url":"https://api.github.com/repos/morepath/reg/issues/37","repository_url":"https://api.github.com/repos/morepath/reg","labels_url":"https://api.github.com/repos/morepath/reg/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/morepath/reg/issues/37/comments","events_url":"https://api.github.com/repos/morepath/reg/issues/37/events","html_url":"https://github.com/morepath/reg/pull/37","id":168031062,"number":37,"title":"Dispatch only","user":{"login":"taschini","id":7879276,"avatar_url":"https://avatars.githubusercontent.com/u/7879276?v=3","gravatar_id":"","url":"https://api.github.com/users/taschini","html_url":"https://github.com/taschini","followers_url":"https://api.github.com/users/taschini/followers","following_url":"https://api.github.com/users/taschini/following{/other_user}","gists_url":"https://api.github.com/users/taschini/gists{/gist_id}","starred_url":"https://api.github.com/users/taschini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taschini/subscriptions","organizations_url":"https://api.github.com/users/taschini/orgs","repos_url":"https://api.github.com/users/taschini/repos","events_url":"https://api.github.com/users/taschini/events{/privacy}","received_events_url":"https://api.github.com/users/taschini/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-07-28T07:29:06Z","updated_at":"2016-08-02T14:15:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/morepath/reg/pulls/37","html_url":"https://github.com/morepath/reg/pull/37","diff_url":"https://github.com/morepath/reg/pull/37.diff","patch_url":"https://github.com/morepath/reg/pull/37.patch"},"body":"This is an experiment steering Reg towards an API that is somewhat closer in spirit to that of ``singledispatch`` or ``Peak-rules``.\r\n\r\nEach generic function has its own ``Registry``, but there is no need to access it directly. The revised ``usage.rst`` shows in detail how to define generic functions, but a quick example should give an idea:\r\n\r\n```python\r\n  @reg.dispatch('item')\r\n  def size(item):\r\n      raise NotImplementedError\r\n\r\n  size.register(document_size, item=Document)\r\n  size.register(folder_size, item=Folder)\r\n  size.register(image_size, item=Image)\r\n  size.register(file_size, item=File)\r\n```\r\n\r\nSince every generic function always know which lookup to use (its own), the implicit lookup machinery is no longer needed and is removed."},"comment":{"url":"https://api.github.com/repos/morepath/reg/issues/comments/236917719","html_url":"https://github.com/morepath/reg/pull/37#issuecomment-236917719","issue_url":"https://api.github.com/repos/morepath/reg/issues/37","id":236917719,"user":{"login":"faassen","id":327472,"avatar_url":"https://avatars.githubusercontent.com/u/327472?v=3","gravatar_id":"","url":"https://api.github.com/users/faassen","html_url":"https://github.com/faassen","followers_url":"https://api.github.com/users/faassen/followers","following_url":"https://api.github.com/users/faassen/following{/other_user}","gists_url":"https://api.github.com/users/faassen/gists{/gist_id}","starred_url":"https://api.github.com/users/faassen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faassen/subscriptions","organizations_url":"https://api.github.com/users/faassen/orgs","repos_url":"https://api.github.com/users/faassen/repos","events_url":"https://api.github.com/users/faassen/events{/privacy}","received_events_url":"https://api.github.com/users/faassen/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T14:15:47Z","updated_at":"2016-08-02T14:15:47Z","body":"Reg on the dispatchmethods branch already has dispatch methods that do this for you, including letting you define a default implementation. It uses Python's method mechanism so make sure the right scope is in use. The scope is contained in the ``lookup`` attribute on the app instance (as opposed to a ``config.scope_registry``).\r\n\r\nHow would this helper-method approach here be any better than the approach I implemented? We seem to have two parallel efforts to accomplish the same thing, and I get the impression you think the way I accomplished this is suboptimal, but I don't quite understand the reasoning yet and it seems the solutions are pretty convergent. I really would like to understand what your problems are with the dispatchmethods approach, so we can make it better or dump it. We can discuss this here but perhaps a this point chat is more efficient.\r\n"}}
{"actor":{"display_login":"faassen"}}