{"action":"created","comment":{"url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/comments/55630116","id":55630116,"diff_hunk":"@@ -0,0 +1,89 @@\n+\"\"\"\n+Pagination support.\n+\n+\"\"\"\n+from flask import request\n+\n+from microcosm_flask.linking import Link, Links\n+from microcosm_flask.operations import Operation\n+\n+\n+class Page(object):\n+    def __init__(self, offset, limit):\n+        self.offset = offset\n+        self.limit = limit\n+\n+    @classmethod\n+    def from_request(cls, default_limit=20):\n+        try:\n+            offset = int(request.args[\"offset\"])\n+        except:\n+            offset = 0\n+        try:\n+            limit = int(request.args[\"limit\"])\n+        except:\n+            limit = default_limit\n+        return cls(offset=offset, limit=limit)\n+\n+    def next(self):\n+        return Page(\n+            offset=self.offset + self.limit,\n+            limit=self.limit,\n+        )\n+\n+    def prev(self):\n+        return Page(\n+            offset=self.offset - self.limit,\n+            limit=self.limit,\n+        )\n+\n+    def to_dict(self):\n+        return dict(\n+            offset=self.offset,\n+            limit=self.limit,\n+        )\n+\n+    def to_tuples(self):\n+        \"\"\"\n+        Convert to tuples for deterministic order when passed to urlencode.\n+\n+        \"\"\"\n+        return [\n+            (\"offset\", self.offset),\n+            (\"limit\", self.limit),\n+        ]\n+\n+\n+class PaginatedList(object):","path":"microcosm_flask/paging.py","position":57,"original_position":57,"commit_id":"64cf9bbecef5af33425156b1c7b7f9048c2dbfee","original_commit_id":"64cf9bbecef5af33425156b1c7b7f9048c2dbfee","user":{"login":"jessemyers","id":477722,"avatar_url":"https://avatars.githubusercontent.com/u/477722?v=3","gravatar_id":"","url":"https://api.github.com/users/jessemyers","html_url":"https://github.com/jessemyers","followers_url":"https://api.github.com/users/jessemyers/followers","following_url":"https://api.github.com/users/jessemyers/following{/other_user}","gists_url":"https://api.github.com/users/jessemyers/gists{/gist_id}","starred_url":"https://api.github.com/users/jessemyers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessemyers/subscriptions","organizations_url":"https://api.github.com/users/jessemyers/orgs","repos_url":"https://api.github.com/users/jessemyers/repos","events_url":"https://api.github.com/users/jessemyers/events{/privacy}","received_events_url":"https://api.github.com/users/jessemyers/received_events","type":"User","site_admin":false},"body":"I'm not using the paginated list yet; it will get fleshed out as soon as I add the CRUD layer.","created_at":"2016-03-10T03:32:45Z","updated_at":"2016-03-10T03:32:45Z","html_url":"https://github.com/globality-corp/microcosm-flask/pull/6#discussion_r55630116","pull_request_url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/comments/55630116"},"html":{"href":"https://github.com/globality-corp/microcosm-flask/pull/6#discussion_r55630116"},"pull_request":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6","id":62334594,"html_url":"https://github.com/globality-corp/microcosm-flask/pull/6","diff_url":"https://github.com/globality-corp/microcosm-flask/pull/6.diff","patch_url":"https://github.com/globality-corp/microcosm-flask/pull/6.patch","issue_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/6","number":6,"state":"open","locked":false,"title":"Add support for linking, pagination, and resource discovery.","user":{"login":"jessemyers","id":477722,"avatar_url":"https://avatars.githubusercontent.com/u/477722?v=3","gravatar_id":"","url":"https://api.github.com/users/jessemyers","html_url":"https://github.com/jessemyers","followers_url":"https://api.github.com/users/jessemyers/followers","following_url":"https://api.github.com/users/jessemyers/following{/other_user}","gists_url":"https://api.github.com/users/jessemyers/gists{/gist_id}","starred_url":"https://api.github.com/users/jessemyers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jessemyers/subscriptions","organizations_url":"https://api.github.com/users/jessemyers/orgs","repos_url":"https://api.github.com/users/jessemyers/repos","events_url":"https://api.github.com/users/jessemyers/events{/privacy}","received_events_url":"https://api.github.com/users/jessemyers/received_events","type":"User","site_admin":false},"body":"Adds the convention that a service has an endpoint where you can find other top-level endpoints.\r\n\r\nIn the process, build out HAL JSON linking and some pagination support.","created_at":"2016-03-10T03:30:12Z","updated_at":"2016-03-10T03:32:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dfbe06636e693b48de7d46cb74f46e29fcc59f32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6/commits","review_comments_url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6/comments","review_comment_url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/comments{/number}","comments_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/6/comments","statuses_url":"https://api.github.com/repos/globality-corp/microcosm-flask/statuses/64cf9bbecef5af33425156b1c7b7f9048c2dbfee","head":{"label":"globality-corp:feature/linking","ref":"feature/linking","sha":"64cf9bbecef5af33425156b1c7b7f9048c2dbfee","user":{"login":"globality-corp","id":11172782,"avatar_url":"https://avatars.githubusercontent.com/u/11172782?v=3","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"repo":{"id":53442595,"name":"microcosm-flask","full_name":"globality-corp/microcosm-flask","owner":{"login":"globality-corp","id":11172782,"avatar_url":"https://avatars.githubusercontent.com/u/11172782?v=3","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/globality-corp/microcosm-flask","description":"Opinionated Flask services","fork":false,"url":"https://api.github.com/repos/globality-corp/microcosm-flask","forks_url":"https://api.github.com/repos/globality-corp/microcosm-flask/forks","keys_url":"https://api.github.com/repos/globality-corp/microcosm-flask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/globality-corp/microcosm-flask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/globality-corp/microcosm-flask/teams","hooks_url":"https://api.github.com/repos/globality-corp/microcosm-flask/hooks","issue_events_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/events{/number}","events_url":"https://api.github.com/repos/globality-corp/microcosm-flask/events","assignees_url":"https://api.github.com/repos/globality-corp/microcosm-flask/assignees{/user}","branches_url":"https://api.github.com/repos/globality-corp/microcosm-flask/branches{/branch}","tags_url":"https://api.github.com/repos/globality-corp/microcosm-flask/tags","blobs_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/refs{/sha}","trees_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/globality-corp/microcosm-flask/statuses/{sha}","languages_url":"https://api.github.com/repos/globality-corp/microcosm-flask/languages","stargazers_url":"https://api.github.com/repos/globality-corp/microcosm-flask/stargazers","contributors_url":"https://api.github.com/repos/globality-corp/microcosm-flask/contributors","subscribers_url":"https://api.github.com/repos/globality-corp/microcosm-flask/subscribers","subscription_url":"https://api.github.com/repos/globality-corp/microcosm-flask/subscription","commits_url":"https://api.github.com/repos/globality-corp/microcosm-flask/commits{/sha}","git_commits_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/commits{/sha}","comments_url":"https://api.github.com/repos/globality-corp/microcosm-flask/comments{/number}","issue_comment_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/comments{/number}","contents_url":"https://api.github.com/repos/globality-corp/microcosm-flask/contents/{+path}","compare_url":"https://api.github.com/repos/globality-corp/microcosm-flask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/globality-corp/microcosm-flask/merges","archive_url":"https://api.github.com/repos/globality-corp/microcosm-flask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/globality-corp/microcosm-flask/downloads","issues_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues{/number}","pulls_url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls{/number}","milestones_url":"https://api.github.com/repos/globality-corp/microcosm-flask/milestones{/number}","notifications_url":"https://api.github.com/repos/globality-corp/microcosm-flask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/globality-corp/microcosm-flask/labels{/name}","releases_url":"https://api.github.com/repos/globality-corp/microcosm-flask/releases{/id}","deployments_url":"https://api.github.com/repos/globality-corp/microcosm-flask/deployments","created_at":"2016-03-08T20:23:55Z","updated_at":"2016-03-09T19:15:55Z","pushed_at":"2016-03-10T03:30:12Z","git_url":"git://github.com/globality-corp/microcosm-flask.git","ssh_url":"git@github.com:globality-corp/microcosm-flask.git","clone_url":"https://github.com/globality-corp/microcosm-flask.git","svn_url":"https://github.com/globality-corp/microcosm-flask","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"globality-corp:develop","ref":"develop","sha":"697cc8f228a80503ed351e7069791b04eb2bd445","user":{"login":"globality-corp","id":11172782,"avatar_url":"https://avatars.githubusercontent.com/u/11172782?v=3","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"repo":{"id":53442595,"name":"microcosm-flask","full_name":"globality-corp/microcosm-flask","owner":{"login":"globality-corp","id":11172782,"avatar_url":"https://avatars.githubusercontent.com/u/11172782?v=3","gravatar_id":"","url":"https://api.github.com/users/globality-corp","html_url":"https://github.com/globality-corp","followers_url":"https://api.github.com/users/globality-corp/followers","following_url":"https://api.github.com/users/globality-corp/following{/other_user}","gists_url":"https://api.github.com/users/globality-corp/gists{/gist_id}","starred_url":"https://api.github.com/users/globality-corp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/globality-corp/subscriptions","organizations_url":"https://api.github.com/users/globality-corp/orgs","repos_url":"https://api.github.com/users/globality-corp/repos","events_url":"https://api.github.com/users/globality-corp/events{/privacy}","received_events_url":"https://api.github.com/users/globality-corp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/globality-corp/microcosm-flask","description":"Opinionated Flask services","fork":false,"url":"https://api.github.com/repos/globality-corp/microcosm-flask","forks_url":"https://api.github.com/repos/globality-corp/microcosm-flask/forks","keys_url":"https://api.github.com/repos/globality-corp/microcosm-flask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/globality-corp/microcosm-flask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/globality-corp/microcosm-flask/teams","hooks_url":"https://api.github.com/repos/globality-corp/microcosm-flask/hooks","issue_events_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/events{/number}","events_url":"https://api.github.com/repos/globality-corp/microcosm-flask/events","assignees_url":"https://api.github.com/repos/globality-corp/microcosm-flask/assignees{/user}","branches_url":"https://api.github.com/repos/globality-corp/microcosm-flask/branches{/branch}","tags_url":"https://api.github.com/repos/globality-corp/microcosm-flask/tags","blobs_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/refs{/sha}","trees_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/globality-corp/microcosm-flask/statuses/{sha}","languages_url":"https://api.github.com/repos/globality-corp/microcosm-flask/languages","stargazers_url":"https://api.github.com/repos/globality-corp/microcosm-flask/stargazers","contributors_url":"https://api.github.com/repos/globality-corp/microcosm-flask/contributors","subscribers_url":"https://api.github.com/repos/globality-corp/microcosm-flask/subscribers","subscription_url":"https://api.github.com/repos/globality-corp/microcosm-flask/subscription","commits_url":"https://api.github.com/repos/globality-corp/microcosm-flask/commits{/sha}","git_commits_url":"https://api.github.com/repos/globality-corp/microcosm-flask/git/commits{/sha}","comments_url":"https://api.github.com/repos/globality-corp/microcosm-flask/comments{/number}","issue_comment_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/comments{/number}","contents_url":"https://api.github.com/repos/globality-corp/microcosm-flask/contents/{+path}","compare_url":"https://api.github.com/repos/globality-corp/microcosm-flask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/globality-corp/microcosm-flask/merges","archive_url":"https://api.github.com/repos/globality-corp/microcosm-flask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/globality-corp/microcosm-flask/downloads","issues_url":"https://api.github.com/repos/globality-corp/microcosm-flask/issues{/number}","pulls_url":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls{/number}","milestones_url":"https://api.github.com/repos/globality-corp/microcosm-flask/milestones{/number}","notifications_url":"https://api.github.com/repos/globality-corp/microcosm-flask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/globality-corp/microcosm-flask/labels{/name}","releases_url":"https://api.github.com/repos/globality-corp/microcosm-flask/releases{/id}","deployments_url":"https://api.github.com/repos/globality-corp/microcosm-flask/deployments","created_at":"2016-03-08T20:23:55Z","updated_at":"2016-03-09T19:15:55Z","pushed_at":"2016-03-10T03:30:12Z","git_url":"git://github.com/globality-corp/microcosm-flask.git","ssh_url":"git@github.com:globality-corp/microcosm-flask.git","clone_url":"https://github.com/globality-corp/microcosm-flask.git","svn_url":"https://github.com/globality-corp/microcosm-flask","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6"},"html":{"href":"https://github.com/globality-corp/microcosm-flask/pull/6"},"issue":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/6"},"comments":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/globality-corp/microcosm-flask/statuses/64cf9bbecef5af33425156b1c7b7f9048c2dbfee"}}}}