{"action":"created","issue":{"url":"https://api.github.com/repos/torchbox/wagtail/issues/2575","repository_url":"https://api.github.com/repos/torchbox/wagtail","labels_url":"https://api.github.com/repos/torchbox/wagtail/issues/2575/labels{/name}","comments_url":"https://api.github.com/repos/torchbox/wagtail/issues/2575/comments","events_url":"https://api.github.com/repos/torchbox/wagtail/issues/2575/events","html_url":"https://github.com/torchbox/wagtail/pull/2575","id":153543259,"number":2575,"title":"Update decorator patterns util to preserve original view method name","user":{"login":"mariocesar","id":25034,"avatar_url":"https://avatars.githubusercontent.com/u/25034?v=3","gravatar_id":"","url":"https://api.github.com/users/mariocesar","html_url":"https://github.com/mariocesar","followers_url":"https://api.github.com/users/mariocesar/followers","following_url":"https://api.github.com/users/mariocesar/following{/other_user}","gists_url":"https://api.github.com/users/mariocesar/gists{/gist_id}","starred_url":"https://api.github.com/users/mariocesar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariocesar/subscriptions","organizations_url":"https://api.github.com/users/mariocesar/orgs","repos_url":"https://api.github.com/users/mariocesar/repos","events_url":"https://api.github.com/users/mariocesar/events{/privacy}","received_events_url":"https://api.github.com/users/mariocesar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-06T21:38:13Z","updated_at":"2016-05-07T06:31:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/torchbox/wagtail/pulls/2575","html_url":"https://github.com/torchbox/wagtail/pull/2575","diff_url":"https://github.com/torchbox/wagtail/pull/2575.diff","patch_url":"https://github.com/torchbox/wagtail/pull/2575.patch"},"body":"When `decorate_urlpatterns` apply a decorator to a view function it lost spec names, docs, and the module where it was imported, making it uneasy to inspect when debugging (Like getting the name view and docs when using `django-debug-toolbar`)\r\n\r\nUsing `functools.wraps` it updates the resulting function to look like the original wrapped view function.\r\n\r\nWithout the use of this decorator factory, the name of the wrapped view function would have been `decorated_view`."},"comment":{"url":"https://api.github.com/repos/torchbox/wagtail/issues/comments/217611275","html_url":"https://github.com/torchbox/wagtail/pull/2575#issuecomment-217611275","issue_url":"https://api.github.com/repos/torchbox/wagtail/issues/2575","id":217611275,"user":{"login":"timheap","id":132147,"avatar_url":"https://avatars.githubusercontent.com/u/132147?v=3","gravatar_id":"","url":"https://api.github.com/users/timheap","html_url":"https://github.com/timheap","followers_url":"https://api.github.com/users/timheap/followers","following_url":"https://api.github.com/users/timheap/following{/other_user}","gists_url":"https://api.github.com/users/timheap/gists{/gist_id}","starred_url":"https://api.github.com/users/timheap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timheap/subscriptions","organizations_url":"https://api.github.com/users/timheap/orgs","repos_url":"https://api.github.com/users/timheap/repos","events_url":"https://api.github.com/users/timheap/events{/privacy}","received_events_url":"https://api.github.com/users/timheap/received_events","type":"User","site_admin":false},"created_at":"2016-05-07T06:31:44Z","updated_at":"2016-05-07T06:31:44Z","body":"Nice one!\r\n\r\nIn cases like this, where you're not using `wraps` as a decorator, `update_wrapper` is a better choice. `wraps` is just a partially applied `update_wrapper` made for decorating functions. This avoids the awkward double brackets `wraps(...)(...)`:\r\n\r\n```python\r\nfrom functools import update_wrapper\r\n\r\npattern._callback = update_wrapper(decorator(pattern.callback), pattern.callback)\r\n```"}}