{"action":"created","comment":{"url":"https://api.github.com/repos/erichiggins/gaek/pulls/comments/84403271","pull_request_review_id":5184711,"id":84403271,"diff_hunk":"@@ -109,28 +134,52 @@ def encode_basevalue(obj):\n   ndb.MetaModel: encode_model,\n   ndb.Query: encode_generator,\n   ndb.QueryIterator: encode_generator,\n-  ndb.Key: encode_key,\n+  ndb.Key: encode_key_as_entity,\n   ndb.Future: encode_future,\n   datetime.date: encode_datetime,\n   datetime.datetime: encode_datetime,\n   time.struct_time: encode_generator,\n   types.ComplexType: encode_complex,\n   ndb.model._BaseValue: encode_basevalue,\n-  \n }\n \n \n class NdbEncoder(json.JSONEncoder):\n   \"\"\"Extend the JSON encoder to add support for NDB Models.\"\"\"\n \n+  _ndb_type_encoding=NDB_TYPE_ENCODING.copy()\n+\n+  def __init__(self, **kwargs):\n+    ndb_keys_as_entities = kwargs.pop('ndb_keys_as_entities', False)\n+    ndb_keys_as_pairs = kwargs.pop('ndb_keys_as_pairs', False)\n+    ndb_keys_as_urlsafe = kwargs.pop('ndb_keys_as_urlsafe', False)\n+\n+    # Validate that only one of three flags is True\n+    if ((ndb_keys_as_entities and ndb_keys_as_pairs)\n+        or (ndb_keys_as_entities and ndb_keys_as_urlsafe)\n+        or (ndb_keys_as_pairs and ndb_keys_as_urlsafe)):\n+      raise NDBJsonInvalidArgumentsError(","path":"gaek/ndb_json.py","position":82,"original_position":82,"commit_id":"8eba67117c41d5a1be260abe562b5bf4b21c6e30","original_commit_id":"8eba67117c41d5a1be260abe562b5bf4b21c6e30","user":{"login":"erichiggins","id":507145,"avatar_url":"https://avatars.githubusercontent.com/u/507145?v=3","gravatar_id":"","url":"https://api.github.com/users/erichiggins","html_url":"https://github.com/erichiggins","followers_url":"https://api.github.com/users/erichiggins/followers","following_url":"https://api.github.com/users/erichiggins/following{/other_user}","gists_url":"https://api.github.com/users/erichiggins/gists{/gist_id}","starred_url":"https://api.github.com/users/erichiggins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichiggins/subscriptions","organizations_url":"https://api.github.com/users/erichiggins/orgs","repos_url":"https://api.github.com/users/erichiggins/repos","events_url":"https://api.github.com/users/erichiggins/events{/privacy}","received_events_url":"https://api.github.com/users/erichiggins/received_events","type":"User","site_admin":false},"body":"Simply raising `ValueError` would be acceptable here since it's a usage issue and not really an internal error.","created_at":"2016-10-21T00:49:22Z","updated_at":"2016-10-21T00:49:22Z","html_url":"https://github.com/erichiggins/gaek/pull/11#discussion_r84403271","pull_request_url":"https://api.github.com/repos/erichiggins/gaek/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/erichiggins/gaek/pulls/comments/84403271"},"html":{"href":"https://github.com/erichiggins/gaek/pull/11#discussion_r84403271"},"pull_request":{"href":"https://api.github.com/repos/erichiggins/gaek/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/erichiggins/gaek/pulls/11","id":86975935,"html_url":"https://github.com/erichiggins/gaek/pull/11","diff_url":"https://github.com/erichiggins/gaek/pull/11.diff","patch_url":"https://github.com/erichiggins/gaek/pull/11.patch","issue_url":"https://api.github.com/repos/erichiggins/gaek/issues/11","number":11,"state":"open","locked":false,"title":"Add a flag fetch_models to specify the way to encode NDB keys","user":{"login":"onufryk","id":597019,"avatar_url":"https://avatars.githubusercontent.com/u/597019?v=3","gravatar_id":"","url":"https://api.github.com/users/onufryk","html_url":"https://github.com/onufryk","followers_url":"https://api.github.com/users/onufryk/followers","following_url":"https://api.github.com/users/onufryk/following{/other_user}","gists_url":"https://api.github.com/users/onufryk/gists{/gist_id}","starred_url":"https://api.github.com/users/onufryk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onufryk/subscriptions","organizations_url":"https://api.github.com/users/onufryk/orgs","repos_url":"https://api.github.com/users/onufryk/repos","events_url":"https://api.github.com/users/onufryk/events{/privacy}","received_events_url":"https://api.github.com/users/onufryk/received_events","type":"User","site_admin":false},"body":"Added a boolean flag `fetch_models` to the constructor of `NdbEncoder`. The flag specifies the way to encode `ndb.Key` properties:\r\n\r\n- `fetch_models=True` (default value): the encoder will get the full entity by its key from the datastore and encode it;\r\n\r\n- `fetch_models=False`: the encoder will encode the ndb.Key as a tuple of (kind, id) pairs. No additional datastore read operations will be performed.\r\n\r\nExample of usage:\r\n`ndb_json.dump(data, dump_file, indent=2, sort_keys=True, fetch_models=False) `","created_at":"2016-09-27T17:32:13Z","updated_at":"2016-10-21T00:56:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4eec33af0d63558b3e99962e4d756215b7ed9650","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/erichiggins/gaek/pulls/11/commits","review_comments_url":"https://api.github.com/repos/erichiggins/gaek/pulls/11/comments","review_comment_url":"https://api.github.com/repos/erichiggins/gaek/pulls/comments{/number}","comments_url":"https://api.github.com/repos/erichiggins/gaek/issues/11/comments","statuses_url":"https://api.github.com/repos/erichiggins/gaek/statuses/8eba67117c41d5a1be260abe562b5bf4b21c6e30","head":{"label":"onufryk:roman/ndb-keys","ref":"roman/ndb-keys","sha":"8eba67117c41d5a1be260abe562b5bf4b21c6e30","user":{"login":"onufryk","id":597019,"avatar_url":"https://avatars.githubusercontent.com/u/597019?v=3","gravatar_id":"","url":"https://api.github.com/users/onufryk","html_url":"https://github.com/onufryk","followers_url":"https://api.github.com/users/onufryk/followers","following_url":"https://api.github.com/users/onufryk/following{/other_user}","gists_url":"https://api.github.com/users/onufryk/gists{/gist_id}","starred_url":"https://api.github.com/users/onufryk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onufryk/subscriptions","organizations_url":"https://api.github.com/users/onufryk/orgs","repos_url":"https://api.github.com/users/onufryk/repos","events_url":"https://api.github.com/users/onufryk/events{/privacy}","received_events_url":"https://api.github.com/users/onufryk/received_events","type":"User","site_admin":false},"repo":{"id":69381487,"name":"gaek","full_name":"onufryk/gaek","owner":{"login":"onufryk","id":597019,"avatar_url":"https://avatars.githubusercontent.com/u/597019?v=3","gravatar_id":"","url":"https://api.github.com/users/onufryk","html_url":"https://github.com/onufryk","followers_url":"https://api.github.com/users/onufryk/followers","following_url":"https://api.github.com/users/onufryk/following{/other_user}","gists_url":"https://api.github.com/users/onufryk/gists{/gist_id}","starred_url":"https://api.github.com/users/onufryk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onufryk/subscriptions","organizations_url":"https://api.github.com/users/onufryk/orgs","repos_url":"https://api.github.com/users/onufryk/repos","events_url":"https://api.github.com/users/onufryk/events{/privacy}","received_events_url":"https://api.github.com/users/onufryk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/onufryk/gaek","description":"A collection of useful tools for Google App Engine.","fork":true,"url":"https://api.github.com/repos/onufryk/gaek","forks_url":"https://api.github.com/repos/onufryk/gaek/forks","keys_url":"https://api.github.com/repos/onufryk/gaek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onufryk/gaek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onufryk/gaek/teams","hooks_url":"https://api.github.com/repos/onufryk/gaek/hooks","issue_events_url":"https://api.github.com/repos/onufryk/gaek/issues/events{/number}","events_url":"https://api.github.com/repos/onufryk/gaek/events","assignees_url":"https://api.github.com/repos/onufryk/gaek/assignees{/user}","branches_url":"https://api.github.com/repos/onufryk/gaek/branches{/branch}","tags_url":"https://api.github.com/repos/onufryk/gaek/tags","blobs_url":"https://api.github.com/repos/onufryk/gaek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onufryk/gaek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onufryk/gaek/git/refs{/sha}","trees_url":"https://api.github.com/repos/onufryk/gaek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onufryk/gaek/statuses/{sha}","languages_url":"https://api.github.com/repos/onufryk/gaek/languages","stargazers_url":"https://api.github.com/repos/onufryk/gaek/stargazers","contributors_url":"https://api.github.com/repos/onufryk/gaek/contributors","subscribers_url":"https://api.github.com/repos/onufryk/gaek/subscribers","subscription_url":"https://api.github.com/repos/onufryk/gaek/subscription","commits_url":"https://api.github.com/repos/onufryk/gaek/commits{/sha}","git_commits_url":"https://api.github.com/repos/onufryk/gaek/git/commits{/sha}","comments_url":"https://api.github.com/repos/onufryk/gaek/comments{/number}","issue_comment_url":"https://api.github.com/repos/onufryk/gaek/issues/comments{/number}","contents_url":"https://api.github.com/repos/onufryk/gaek/contents/{+path}","compare_url":"https://api.github.com/repos/onufryk/gaek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onufryk/gaek/merges","archive_url":"https://api.github.com/repos/onufryk/gaek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onufryk/gaek/downloads","issues_url":"https://api.github.com/repos/onufryk/gaek/issues{/number}","pulls_url":"https://api.github.com/repos/onufryk/gaek/pulls{/number}","milestones_url":"https://api.github.com/repos/onufryk/gaek/milestones{/number}","notifications_url":"https://api.github.com/repos/onufryk/gaek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onufryk/gaek/labels{/name}","releases_url":"https://api.github.com/repos/onufryk/gaek/releases{/id}","deployments_url":"https://api.github.com/repos/onufryk/gaek/deployments","created_at":"2016-09-27T17:26:11Z","updated_at":"2016-09-27T17:26:12Z","pushed_at":"2016-10-20T23:55:44Z","git_url":"git://github.com/onufryk/gaek.git","ssh_url":"git@github.com:onufryk/gaek.git","clone_url":"https://github.com/onufryk/gaek.git","svn_url":"https://github.com/onufryk/gaek","homepage":null,"size":51,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"erichiggins:develop","ref":"develop","sha":"db05dd6cd276ad3674a703a4cd4e6f5a2bbc2199","user":{"login":"erichiggins","id":507145,"avatar_url":"https://avatars.githubusercontent.com/u/507145?v=3","gravatar_id":"","url":"https://api.github.com/users/erichiggins","html_url":"https://github.com/erichiggins","followers_url":"https://api.github.com/users/erichiggins/followers","following_url":"https://api.github.com/users/erichiggins/following{/other_user}","gists_url":"https://api.github.com/users/erichiggins/gists{/gist_id}","starred_url":"https://api.github.com/users/erichiggins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichiggins/subscriptions","organizations_url":"https://api.github.com/users/erichiggins/orgs","repos_url":"https://api.github.com/users/erichiggins/repos","events_url":"https://api.github.com/users/erichiggins/events{/privacy}","received_events_url":"https://api.github.com/users/erichiggins/received_events","type":"User","site_admin":false},"repo":{"id":19851012,"name":"gaek","full_name":"erichiggins/gaek","owner":{"login":"erichiggins","id":507145,"avatar_url":"https://avatars.githubusercontent.com/u/507145?v=3","gravatar_id":"","url":"https://api.github.com/users/erichiggins","html_url":"https://github.com/erichiggins","followers_url":"https://api.github.com/users/erichiggins/followers","following_url":"https://api.github.com/users/erichiggins/following{/other_user}","gists_url":"https://api.github.com/users/erichiggins/gists{/gist_id}","starred_url":"https://api.github.com/users/erichiggins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erichiggins/subscriptions","organizations_url":"https://api.github.com/users/erichiggins/orgs","repos_url":"https://api.github.com/users/erichiggins/repos","events_url":"https://api.github.com/users/erichiggins/events{/privacy}","received_events_url":"https://api.github.com/users/erichiggins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/erichiggins/gaek","description":"A collection of useful tools for Google App Engine.","fork":false,"url":"https://api.github.com/repos/erichiggins/gaek","forks_url":"https://api.github.com/repos/erichiggins/gaek/forks","keys_url":"https://api.github.com/repos/erichiggins/gaek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/erichiggins/gaek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/erichiggins/gaek/teams","hooks_url":"https://api.github.com/repos/erichiggins/gaek/hooks","issue_events_url":"https://api.github.com/repos/erichiggins/gaek/issues/events{/number}","events_url":"https://api.github.com/repos/erichiggins/gaek/events","assignees_url":"https://api.github.com/repos/erichiggins/gaek/assignees{/user}","branches_url":"https://api.github.com/repos/erichiggins/gaek/branches{/branch}","tags_url":"https://api.github.com/repos/erichiggins/gaek/tags","blobs_url":"https://api.github.com/repos/erichiggins/gaek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/erichiggins/gaek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/erichiggins/gaek/git/refs{/sha}","trees_url":"https://api.github.com/repos/erichiggins/gaek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/erichiggins/gaek/statuses/{sha}","languages_url":"https://api.github.com/repos/erichiggins/gaek/languages","stargazers_url":"https://api.github.com/repos/erichiggins/gaek/stargazers","contributors_url":"https://api.github.com/repos/erichiggins/gaek/contributors","subscribers_url":"https://api.github.com/repos/erichiggins/gaek/subscribers","subscription_url":"https://api.github.com/repos/erichiggins/gaek/subscription","commits_url":"https://api.github.com/repos/erichiggins/gaek/commits{/sha}","git_commits_url":"https://api.github.com/repos/erichiggins/gaek/git/commits{/sha}","comments_url":"https://api.github.com/repos/erichiggins/gaek/comments{/number}","issue_comment_url":"https://api.github.com/repos/erichiggins/gaek/issues/comments{/number}","contents_url":"https://api.github.com/repos/erichiggins/gaek/contents/{+path}","compare_url":"https://api.github.com/repos/erichiggins/gaek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/erichiggins/gaek/merges","archive_url":"https://api.github.com/repos/erichiggins/gaek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/erichiggins/gaek/downloads","issues_url":"https://api.github.com/repos/erichiggins/gaek/issues{/number}","pulls_url":"https://api.github.com/repos/erichiggins/gaek/pulls{/number}","milestones_url":"https://api.github.com/repos/erichiggins/gaek/milestones{/number}","notifications_url":"https://api.github.com/repos/erichiggins/gaek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/erichiggins/gaek/labels{/name}","releases_url":"https://api.github.com/repos/erichiggins/gaek/releases{/id}","deployments_url":"https://api.github.com/repos/erichiggins/gaek/deployments","created_at":"2014-05-16T09:18:07Z","updated_at":"2016-06-03T22:10:56Z","pushed_at":"2016-10-21T00:08:53Z","git_url":"git://github.com/erichiggins/gaek.git","ssh_url":"git@github.com:erichiggins/gaek.git","clone_url":"https://github.com/erichiggins/gaek.git","svn_url":"https://github.com/erichiggins/gaek","homepage":null,"size":48,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":6,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/erichiggins/gaek/pulls/11"},"html":{"href":"https://github.com/erichiggins/gaek/pull/11"},"issue":{"href":"https://api.github.com/repos/erichiggins/gaek/issues/11"},"comments":{"href":"https://api.github.com/repos/erichiggins/gaek/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/erichiggins/gaek/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/erichiggins/gaek/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/erichiggins/gaek/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/erichiggins/gaek/statuses/8eba67117c41d5a1be260abe562b5bf4b21c6e30"}}}}
{"actor":{"display_login":"erichiggins"}}