GitHub PullRequestReviewCommentEvent at 2014-12-07 12:01:41
Repository: django-rest-framework
Actor: Ian-Foote
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/21423955","id":21423955,"diff_hunk":"@@ -462,6 +462,42 @@ def get_value(self, dictionary):\n             return html.parse_html_list(dictionary, prefix=self.field_name)\n         return dictionary.get(self.field_name, empty)\n \n+    def run_validation(self, data=empty):\n+        data = super(ListSerializer, self).run_validation(data)\n+\n+        try:\n+            data = self.validate(data)\n+            assert data is not None, '.validate() should return the validated data'\n+        except ValidationError as exc:\n+            if isinstance(exc.detail, dict):\n+                # .validate() errors may be a dict, in which case, use\n+                # standard {key: list of values} style.\n+                raise ValidationError(dict([\n+                    (key, value if isinstance(value, list) else [value])\n+                    for key, value in exc.detail.items()\n+                ]))\n+            elif isinstance(exc.detail, list):\n+                raise ValidationError({\n+                    api_settings.NON_FIELD_ERRORS_KEY: exc.detail\n+                })\n+            else:\n+                raise ValidationError({\n+                    api_settings.NON_FIELD_ERRORS_KEY: [exc.detail]\n+                })\n+        except DjangoValidationError as exc:\n+            # Normally you should raise `serializers.ValidationError`\n+            # inside your codebase, but we handle Django's validation\n+            # exception class as well for simpler compat.\n+            # Eg. Calling Model.clean() explicitly inside Serializer.validate()\n+            raise ValidationError({\n+                api_settings.NON_FIELD_ERRORS_KEY: list(exc.messages)\n+            })","path":"rest_framework/serializers.py","position":33,"original_position":33,"commit_id":"345bf42ce989b2361ad90617130b82c53d7fbb03","original_commit_id":"345bf42ce989b2361ad90617130b82c53d7fbb03","user":{"login":"Ian-Foote","id":1843202,"avatar_url":"https://avatars.githubusercontent.com/u/1843202?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"body":"This is a large copy/paste from `Serializer.run_validation`. I would prefer to refactor this to be more DRY, but I'm not sure how best to do this.","created_at":"2014-12-07T12:01:41Z","updated_at":"2014-12-07T12:01:41Z","html_url":"https://github.com/tomchristie/django-rest-framework/pull/2225#discussion_r21423955","pull_request_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225","_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/21423955"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/2225#discussion_r21423955"},"pull_request":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225"}}},"pull_request":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225","id":25631296,"html_url":"https://github.com/tomchristie/django-rest-framework/pull/2225","diff_url":"https://github.com/tomchristie/django-rest-framework/pull/2225.diff","patch_url":"https://github.com/tomchristie/django-rest-framework/pull/2225.patch","issue_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2225","number":2225,"state":"open","locked":false,"title":"Add validate method back to ListSerializer","user":{"login":"Ian-Foote","id":1843202,"avatar_url":"https://avatars.githubusercontent.com/u/1843202?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"body":"Fixes #2168.","created_at":"2014-12-07T12:00:15Z","updated_at":"2014-12-07T12:01:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0fa4ea938716e88ebc05c45673b795fcff5c335","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225/commits","review_comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225/comments","review_comment_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/{number}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2225/comments","statuses_url":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/345bf42ce989b2361ad90617130b82c53d7fbb03","head":{"label":"Ian-Foote:list-serializer-validate","ref":"list-serializer-validate","sha":"345bf42ce989b2361ad90617130b82c53d7fbb03","user":{"login":"Ian-Foote","id":1843202,"avatar_url":"https://avatars.githubusercontent.com/u/1843202?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"repo":{"id":14712431,"name":"django-rest-framework","full_name":"Ian-Foote/django-rest-framework","owner":{"login":"Ian-Foote","id":1843202,"avatar_url":"https://avatars.githubusercontent.com/u/1843202?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ian-Foote/django-rest-framework","description":"Awesome web-browseable Web APIs.","fork":true,"url":"https://api.github.com/repos/Ian-Foote/django-rest-framework","forks_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/forks","keys_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/teams","hooks_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/hooks","issue_events_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/issues/events{/number}","events_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/events","assignees_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/assignees{/user}","branches_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/branches{/branch}","tags_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/tags","blobs_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/languages","stargazers_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/stargazers","contributors_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/contributors","subscribers_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/subscribers","subscription_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/subscription","commits_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/contents/{+path}","compare_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/merges","archive_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/downloads","issues_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/issues{/number}","pulls_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/labels{/name}","releases_url":"https://api.github.com/repos/Ian-Foote/django-rest-framework/releases{/id}","created_at":"2013-11-26T09:30:24Z","updated_at":"2014-12-07T11:19:50Z","pushed_at":"2014-12-07T11:59:38Z","git_url":"git://github.com/Ian-Foote/django-rest-framework.git","ssh_url":"git@github.com:Ian-Foote/django-rest-framework.git","clone_url":"https://github.com/Ian-Foote/django-rest-framework.git","svn_url":"https://github.com/Ian-Foote/django-rest-framework","homepage":"django-rest-framework.org","size":10096,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tomchristie:master","ref":"master","sha":"71c49fea8abf1007d17aaf801dab9099b36515bd","user":{"login":"tomchristie","id":647359,"avatar_url":"https://avatars.githubusercontent.com/u/647359?v=3","gravatar_id":"","url":"https://api.github.com/users/tomchristie","html_url":"https://github.com/tomchristie","followers_url":"https://api.github.com/users/tomchristie/followers","following_url":"https://api.github.com/users/tomchristie/following{/other_user}","gists_url":"https://api.github.com/users/tomchristie/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchristie/subscriptions","organizations_url":"https://api.github.com/users/tomchristie/orgs","repos_url":"https://api.github.com/users/tomchristie/repos","events_url":"https://api.github.com/users/tomchristie/events{/privacy}","received_events_url":"https://api.github.com/users/tomchristie/received_events","type":"User","site_admin":false},"repo":{"id":1431547,"name":"django-rest-framework","full_name":"tomchristie/django-rest-framework","owner":{"login":"tomchristie","id":647359,"avatar_url":"https://avatars.githubusercontent.com/u/647359?v=3","gravatar_id":"","url":"https://api.github.com/users/tomchristie","html_url":"https://github.com/tomchristie","followers_url":"https://api.github.com/users/tomchristie/followers","following_url":"https://api.github.com/users/tomchristie/following{/other_user}","gists_url":"https://api.github.com/users/tomchristie/gists{/gist_id}","starred_url":"https://api.github.com/users/tomchristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomchristie/subscriptions","organizations_url":"https://api.github.com/users/tomchristie/orgs","repos_url":"https://api.github.com/users/tomchristie/repos","events_url":"https://api.github.com/users/tomchristie/events{/privacy}","received_events_url":"https://api.github.com/users/tomchristie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tomchristie/django-rest-framework","description":"Web APIs for Django.","fork":false,"url":"https://api.github.com/repos/tomchristie/django-rest-framework","forks_url":"https://api.github.com/repos/tomchristie/django-rest-framework/forks","keys_url":"https://api.github.com/repos/tomchristie/django-rest-framework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tomchristie/django-rest-framework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tomchristie/django-rest-framework/teams","hooks_url":"https://api.github.com/repos/tomchristie/django-rest-framework/hooks","issue_events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/events{/number}","events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/events","assignees_url":"https://api.github.com/repos/tomchristie/django-rest-framework/assignees{/user}","branches_url":"https://api.github.com/repos/tomchristie/django-rest-framework/branches{/branch}","tags_url":"https://api.github.com/repos/tomchristie/django-rest-framework/tags","blobs_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/refs{/sha}","trees_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/{sha}","languages_url":"https://api.github.com/repos/tomchristie/django-rest-framework/languages","stargazers_url":"https://api.github.com/repos/tomchristie/django-rest-framework/stargazers","contributors_url":"https://api.github.com/repos/tomchristie/django-rest-framework/contributors","subscribers_url":"https://api.github.com/repos/tomchristie/django-rest-framework/subscribers","subscription_url":"https://api.github.com/repos/tomchristie/django-rest-framework/subscription","commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/commits{/sha}","git_commits_url":"https://api.github.com/repos/tomchristie/django-rest-framework/git/commits{/sha}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/comments{/number}","issue_comment_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/comments/{number}","contents_url":"https://api.github.com/repos/tomchristie/django-rest-framework/contents/{+path}","compare_url":"https://api.github.com/repos/tomchristie/django-rest-framework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tomchristie/django-rest-framework/merges","archive_url":"https://api.github.com/repos/tomchristie/django-rest-framework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tomchristie/django-rest-framework/downloads","issues_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues{/number}","pulls_url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls{/number}","milestones_url":"https://api.github.com/repos/tomchristie/django-rest-framework/milestones{/number}","notifications_url":"https://api.github.com/repos/tomchristie/django-rest-framework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tomchristie/django-rest-framework/labels{/name}","releases_url":"https://api.github.com/repos/tomchristie/django-rest-framework/releases{/id}","created_at":"2011-03-02T17:13:56Z","updated_at":"2014-12-07T10:28:33Z","pushed_at":"2014-12-06T10:14:17Z","git_url":"git://github.com/tomchristie/django-rest-framework.git","ssh_url":"git@github.com:tomchristie/django-rest-framework.git","clone_url":"https://github.com/tomchristie/django-rest-framework.git","svn_url":"https://github.com/tomchristie/django-rest-framework","homepage":"www.django-rest-framework.org","size":27319,"stargazers_count":3239,"watchers_count":3239,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":992,"mirror_url":null,"open_issues_count":88,"forks":992,"open_issues":88,"watchers":3239,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225"},"html":{"href":"https://github.com/tomchristie/django-rest-framework/pull/2225"},"issue":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2225"},"comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2225/comments"},"review_comments":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225/comments"},"review_comment":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2225/commits"},"statuses":{"href":"https://api.github.com/repos/tomchristie/django-rest-framework/statuses/345bf42ce989b2361ad90617130b82c53d7fbb03"}}}}