{"action":"created","comment":{"url":"https://api.github.com/repos/schematics/schematics/pulls/comments/26819097","id":26819097,"diff_hunk":"@@ -156,6 +156,10 @@ def export_loop(cls, instance_or_dict, field_converter,\n         raise ValueError(error_msg % (cls.__name__, role))\n     else:\n         gottago = cls._options.roles.get(\"default\", gottago)\n+    if hasattr(cls, '_options') and hasattr(cls._options, 'fields_order'):\n+        fields_order = cls._options.fields_order\n+        if fields_order is not None:","path":"schematics/transforms.py","position":6,"original_position":6,"commit_id":"0810550b5254a8c6a9e6520334c787539674fd58","original_commit_id":"0810550b5254a8c6a9e6520334c787539674fd58","user":{"login":"kracekumar","id":311929,"avatar_url":"https://avatars.githubusercontent.com/u/311929?v=3","gravatar_id":"","url":"https://api.github.com/users/kracekumar","html_url":"https://github.com/kracekumar","followers_url":"https://api.github.com/users/kracekumar/followers","following_url":"https://api.github.com/users/kracekumar/following{/other_user}","gists_url":"https://api.github.com/users/kracekumar/gists{/gist_id}","starred_url":"https://api.github.com/users/kracekumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kracekumar/subscriptions","organizations_url":"https://api.github.com/users/kracekumar/orgs","repos_url":"https://api.github.com/users/kracekumar/repos","events_url":"https://api.github.com/users/kracekumar/events{/privacy}","received_events_url":"https://api.github.com/users/kracekumar/received_events","type":"User","site_admin":false},"body":"How about `if not fields_order` ?","created_at":"2015-03-20T05:11:22Z","updated_at":"2015-03-20T05:11:22Z","html_url":"https://github.com/schematics/schematics/pull/297#discussion_r26819097","pull_request_url":"https://api.github.com/repos/schematics/schematics/pulls/297","_links":{"self":{"href":"https://api.github.com/repos/schematics/schematics/pulls/comments/26819097"},"html":{"href":"https://github.com/schematics/schematics/pull/297#discussion_r26819097"},"pull_request":{"href":"https://api.github.com/repos/schematics/schematics/pulls/297"}}},"pull_request":{"url":"https://api.github.com/repos/schematics/schematics/pulls/297","id":31578309,"html_url":"https://github.com/schematics/schematics/pull/297","diff_url":"https://github.com/schematics/schematics/pull/297.diff","patch_url":"https://github.com/schematics/schematics/pull/297.patch","issue_url":"https://api.github.com/repos/schematics/schematics/issues/297","number":297,"state":"open","locked":false,"title":"Support for fields order in serialized format via Options class in model","user":{"login":"delicb","id":131180,"avatar_url":"https://avatars.githubusercontent.com/u/131180?v=3","gravatar_id":"","url":"https://api.github.com/users/delicb","html_url":"https://github.com/delicb","followers_url":"https://api.github.com/users/delicb/followers","following_url":"https://api.github.com/users/delicb/following{/other_user}","gists_url":"https://api.github.com/users/delicb/gists{/gist_id}","starred_url":"https://api.github.com/users/delicb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delicb/subscriptions","organizations_url":"https://api.github.com/users/delicb/orgs","repos_url":"https://api.github.com/users/delicb/repos","events_url":"https://api.github.com/users/delicb/events{/privacy}","received_events_url":"https://api.github.com/users/delicb/received_events","type":"User","site_admin":false},"body":"I have implemented simple way of declaring order of fields in serialized output. \r\nSomething like this does not have great technical value, but it is nice to return dictionary always in the same format when using schematics as validation layer for REST API (which is the way that I am using it).\r\n\r\nThis might not be the best way to implement this, but it reflects just the thing that I need. \r\n\r\nI was not sure what to do with fields that are not specified in `fields_order` list, so I did nothing and in that case order of fields is not guaranteed in any way, just as it is not guaranteed with `dict` (well, fields that are mentioned in `fields_order` will be pushed back, other fields will be left in front, but that is just a side effect).\r\n\r\nWhat do you think?\r\n\r\nI am opened to suggestions, if you have any.","created_at":"2015-03-20T00:06:46Z","updated_at":"2015-03-20T05:11:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"222fccf61e1cef9f0eecfd730b36d617eee7f052","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/schematics/schematics/pulls/297/commits","review_comments_url":"https://api.github.com/repos/schematics/schematics/pulls/297/comments","review_comment_url":"https://api.github.com/repos/schematics/schematics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/schematics/schematics/issues/297/comments","statuses_url":"https://api.github.com/repos/schematics/schematics/statuses/0810550b5254a8c6a9e6520334c787539674fd58","head":{"label":"delicb:development","ref":"development","sha":"0810550b5254a8c6a9e6520334c787539674fd58","user":{"login":"delicb","id":131180,"avatar_url":"https://avatars.githubusercontent.com/u/131180?v=3","gravatar_id":"","url":"https://api.github.com/users/delicb","html_url":"https://github.com/delicb","followers_url":"https://api.github.com/users/delicb/followers","following_url":"https://api.github.com/users/delicb/following{/other_user}","gists_url":"https://api.github.com/users/delicb/gists{/gist_id}","starred_url":"https://api.github.com/users/delicb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delicb/subscriptions","organizations_url":"https://api.github.com/users/delicb/orgs","repos_url":"https://api.github.com/users/delicb/repos","events_url":"https://api.github.com/users/delicb/events{/privacy}","received_events_url":"https://api.github.com/users/delicb/received_events","type":"User","site_admin":false},"repo":{"id":32548735,"name":"schematics","full_name":"delicb/schematics","owner":{"login":"delicb","id":131180,"avatar_url":"https://avatars.githubusercontent.com/u/131180?v=3","gravatar_id":"","url":"https://api.github.com/users/delicb","html_url":"https://github.com/delicb","followers_url":"https://api.github.com/users/delicb/followers","following_url":"https://api.github.com/users/delicb/following{/other_user}","gists_url":"https://api.github.com/users/delicb/gists{/gist_id}","starred_url":"https://api.github.com/users/delicb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delicb/subscriptions","organizations_url":"https://api.github.com/users/delicb/orgs","repos_url":"https://api.github.com/users/delicb/repos","events_url":"https://api.github.com/users/delicb/events{/privacy}","received_events_url":"https://api.github.com/users/delicb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/delicb/schematics","description":"Python Data Structures for Humans™.","fork":true,"url":"https://api.github.com/repos/delicb/schematics","forks_url":"https://api.github.com/repos/delicb/schematics/forks","keys_url":"https://api.github.com/repos/delicb/schematics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/delicb/schematics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/delicb/schematics/teams","hooks_url":"https://api.github.com/repos/delicb/schematics/hooks","issue_events_url":"https://api.github.com/repos/delicb/schematics/issues/events{/number}","events_url":"https://api.github.com/repos/delicb/schematics/events","assignees_url":"https://api.github.com/repos/delicb/schematics/assignees{/user}","branches_url":"https://api.github.com/repos/delicb/schematics/branches{/branch}","tags_url":"https://api.github.com/repos/delicb/schematics/tags","blobs_url":"https://api.github.com/repos/delicb/schematics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/delicb/schematics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/delicb/schematics/git/refs{/sha}","trees_url":"https://api.github.com/repos/delicb/schematics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/delicb/schematics/statuses/{sha}","languages_url":"https://api.github.com/repos/delicb/schematics/languages","stargazers_url":"https://api.github.com/repos/delicb/schematics/stargazers","contributors_url":"https://api.github.com/repos/delicb/schematics/contributors","subscribers_url":"https://api.github.com/repos/delicb/schematics/subscribers","subscription_url":"https://api.github.com/repos/delicb/schematics/subscription","commits_url":"https://api.github.com/repos/delicb/schematics/commits{/sha}","git_commits_url":"https://api.github.com/repos/delicb/schematics/git/commits{/sha}","comments_url":"https://api.github.com/repos/delicb/schematics/comments{/number}","issue_comment_url":"https://api.github.com/repos/delicb/schematics/issues/comments{/number}","contents_url":"https://api.github.com/repos/delicb/schematics/contents/{+path}","compare_url":"https://api.github.com/repos/delicb/schematics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/delicb/schematics/merges","archive_url":"https://api.github.com/repos/delicb/schematics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/delicb/schematics/downloads","issues_url":"https://api.github.com/repos/delicb/schematics/issues{/number}","pulls_url":"https://api.github.com/repos/delicb/schematics/pulls{/number}","milestones_url":"https://api.github.com/repos/delicb/schematics/milestones{/number}","notifications_url":"https://api.github.com/repos/delicb/schematics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/delicb/schematics/labels{/name}","releases_url":"https://api.github.com/repos/delicb/schematics/releases{/id}","created_at":"2015-03-19T22:07:23Z","updated_at":"2015-03-20T00:06:22Z","pushed_at":"2015-03-20T00:06:22Z","git_url":"git://github.com/delicb/schematics.git","ssh_url":"git@github.com:delicb/schematics.git","clone_url":"https://github.com/delicb/schematics.git","svn_url":"https://github.com/delicb/schematics","homepage":"http://schematics.readthedocs.org/","size":2882,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"development"}},"base":{"label":"schematics:development","ref":"development","sha":"c918333b67514b00b0aeb0db02d5f01b29a8969d","user":{"login":"schematics","id":7866441,"avatar_url":"https://avatars.githubusercontent.com/u/7866441?v=3","gravatar_id":"","url":"https://api.github.com/users/schematics","html_url":"https://github.com/schematics","followers_url":"https://api.github.com/users/schematics/followers","following_url":"https://api.github.com/users/schematics/following{/other_user}","gists_url":"https://api.github.com/users/schematics/gists{/gist_id}","starred_url":"https://api.github.com/users/schematics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schematics/subscriptions","organizations_url":"https://api.github.com/users/schematics/orgs","repos_url":"https://api.github.com/users/schematics/repos","events_url":"https://api.github.com/users/schematics/events{/privacy}","received_events_url":"https://api.github.com/users/schematics/received_events","type":"Organization","site_admin":false},"repo":{"id":1199632,"name":"schematics","full_name":"schematics/schematics","owner":{"login":"schematics","id":7866441,"avatar_url":"https://avatars.githubusercontent.com/u/7866441?v=3","gravatar_id":"","url":"https://api.github.com/users/schematics","html_url":"https://github.com/schematics","followers_url":"https://api.github.com/users/schematics/followers","following_url":"https://api.github.com/users/schematics/following{/other_user}","gists_url":"https://api.github.com/users/schematics/gists{/gist_id}","starred_url":"https://api.github.com/users/schematics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schematics/subscriptions","organizations_url":"https://api.github.com/users/schematics/orgs","repos_url":"https://api.github.com/users/schematics/repos","events_url":"https://api.github.com/users/schematics/events{/privacy}","received_events_url":"https://api.github.com/users/schematics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/schematics/schematics","description":"Python Data Structures for Humans™.","fork":false,"url":"https://api.github.com/repos/schematics/schematics","forks_url":"https://api.github.com/repos/schematics/schematics/forks","keys_url":"https://api.github.com/repos/schematics/schematics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schematics/schematics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schematics/schematics/teams","hooks_url":"https://api.github.com/repos/schematics/schematics/hooks","issue_events_url":"https://api.github.com/repos/schematics/schematics/issues/events{/number}","events_url":"https://api.github.com/repos/schematics/schematics/events","assignees_url":"https://api.github.com/repos/schematics/schematics/assignees{/user}","branches_url":"https://api.github.com/repos/schematics/schematics/branches{/branch}","tags_url":"https://api.github.com/repos/schematics/schematics/tags","blobs_url":"https://api.github.com/repos/schematics/schematics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schematics/schematics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schematics/schematics/git/refs{/sha}","trees_url":"https://api.github.com/repos/schematics/schematics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schematics/schematics/statuses/{sha}","languages_url":"https://api.github.com/repos/schematics/schematics/languages","stargazers_url":"https://api.github.com/repos/schematics/schematics/stargazers","contributors_url":"https://api.github.com/repos/schematics/schematics/contributors","subscribers_url":"https://api.github.com/repos/schematics/schematics/subscribers","subscription_url":"https://api.github.com/repos/schematics/schematics/subscription","commits_url":"https://api.github.com/repos/schematics/schematics/commits{/sha}","git_commits_url":"https://api.github.com/repos/schematics/schematics/git/commits{/sha}","comments_url":"https://api.github.com/repos/schematics/schematics/comments{/number}","issue_comment_url":"https://api.github.com/repos/schematics/schematics/issues/comments{/number}","contents_url":"https://api.github.com/repos/schematics/schematics/contents/{+path}","compare_url":"https://api.github.com/repos/schematics/schematics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schematics/schematics/merges","archive_url":"https://api.github.com/repos/schematics/schematics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schematics/schematics/downloads","issues_url":"https://api.github.com/repos/schematics/schematics/issues{/number}","pulls_url":"https://api.github.com/repos/schematics/schematics/pulls{/number}","milestones_url":"https://api.github.com/repos/schematics/schematics/milestones{/number}","notifications_url":"https://api.github.com/repos/schematics/schematics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schematics/schematics/labels{/name}","releases_url":"https://api.github.com/repos/schematics/schematics/releases{/id}","created_at":"2010-12-27T02:25:29Z","updated_at":"2015-03-17T14:00:52Z","pushed_at":"2015-03-20T00:06:47Z","git_url":"git://github.com/schematics/schematics.git","ssh_url":"git@github.com:schematics/schematics.git","clone_url":"https://github.com/schematics/schematics.git","svn_url":"https://github.com/schematics/schematics","homepage":"http://schematics.readthedocs.org/","size":2882,"stargazers_count":1330,"watchers_count":1330,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":158,"mirror_url":null,"open_issues_count":52,"forks":158,"open_issues":52,"watchers":1330,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/schematics/schematics/pulls/297"},"html":{"href":"https://github.com/schematics/schematics/pull/297"},"issue":{"href":"https://api.github.com/repos/schematics/schematics/issues/297"},"comments":{"href":"https://api.github.com/repos/schematics/schematics/issues/297/comments"},"review_comments":{"href":"https://api.github.com/repos/schematics/schematics/pulls/297/comments"},"review_comment":{"href":"https://api.github.com/repos/schematics/schematics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/schematics/schematics/pulls/297/commits"},"statuses":{"href":"https://api.github.com/repos/schematics/schematics/statuses/0810550b5254a8c6a9e6520334c787539674fd58"}}}}