{"action":"created","comment":{"url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/comments/59124701","id":59124701,"diff_hunk":"@@ -0,0 +1,55 @@\n+from tornado import gen\n+import rethinkdb as r\n+import logging\n+\n+from .config import CONFIG\n+\n+\n+r.set_loop_type(\"tornado\")\n+FORMAT = '[%(levelname)1.1s %(asctime)s %(name)s:%(lineno)d] %(message)s'\n+\n+\n+class RethinkDB(object):\n+    def __init__(self, dbname, tables):\n+        self._connection = None\n+        self.dbname = dbname\n+        self.tables = tables\n+        logging.basicConfig(format=FORMAT)\n+        self.logger = logging.getLogger(\"rethinkdb.\" + dbname)\n+\n+    @gen.coroutine\n+    def connection(self):\n+        # loop makes sure that the connection object has been completely\n+        # initialized before we use it (note that we only set the\n+        # self._connection object at the END of self.init()\n+        while self._connection is None:\n+            yield gen.sleep(0)\n+        conn = yield self._connection\n+        return conn\n+\n+    @gen.coroutine\n+    def init(self):\n+        self.logger.info(\"Initializing connection to DB\")\n+        connection = r.connect(\n+            host=CONFIG.get('rethink_host'),\n+            port=int(CONFIG.get('rethink_port')),","path":"lib/dbhelper.py","position":52,"original_position":35,"commit_id":"a439049e54537b504ecba4c9dd76b99222004b5e","original_commit_id":"f4557ce3c3f5615b6bd4f62665f6f9194fdf15a1","user":{"login":"mynameisfiber","id":47370,"avatar_url":"https://avatars.githubusercontent.com/u/47370?v=3","gravatar_id":"","url":"https://api.github.com/users/mynameisfiber","html_url":"https://github.com/mynameisfiber","followers_url":"https://api.github.com/users/mynameisfiber/followers","following_url":"https://api.github.com/users/mynameisfiber/following{/other_user}","gists_url":"https://api.github.com/users/mynameisfiber/gists{/gist_id}","starred_url":"https://api.github.com/users/mynameisfiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mynameisfiber/subscriptions","organizations_url":"https://api.github.com/users/mynameisfiber/orgs","repos_url":"https://api.github.com/users/mynameisfiber/repos","events_url":"https://api.github.com/users/mynameisfiber/events{/privacy}","received_events_url":"https://api.github.com/users/mynameisfiber/received_events","type":"User","site_admin":false},"body":"I even had that in it's own commit f4557ce3c3f5615b6bd4f62665f6f9194fdf15a1 :D","created_at":"2016-04-10T00:46:08Z","updated_at":"2016-04-10T00:46:08Z","html_url":"https://github.com/QuantifiedSelfless/gulper/pull/22#discussion_r59124701","pull_request_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/comments/59124701"},"html":{"href":"https://github.com/QuantifiedSelfless/gulper/pull/22#discussion_r59124701"},"pull_request":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22","id":65896271,"html_url":"https://github.com/QuantifiedSelfless/gulper/pull/22","diff_url":"https://github.com/QuantifiedSelfless/gulper/pull/22.diff","patch_url":"https://github.com/QuantifiedSelfless/gulper/pull/22.patch","issue_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/22","number":22,"state":"open","locked":false,"title":"Exhibit permissions","user":{"login":"mynameisfiber","id":47370,"avatar_url":"https://avatars.githubusercontent.com/u/47370?v=3","gravatar_id":"","url":"https://api.github.com/users/mynameisfiber","html_url":"https://github.com/mynameisfiber","followers_url":"https://api.github.com/users/mynameisfiber/followers","following_url":"https://api.github.com/users/mynameisfiber/following{/other_user}","gists_url":"https://api.github.com/users/mynameisfiber/gists{/gist_id}","starred_url":"https://api.github.com/users/mynameisfiber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mynameisfiber/subscriptions","organizations_url":"https://api.github.com/users/mynameisfiber/orgs","repos_url":"https://api.github.com/users/mynameisfiber/repos","events_url":"https://api.github.com/users/mynameisfiber/events{/privacy}","received_events_url":"https://api.github.com/users/mynameisfiber/received_events","type":"User","site_admin":false},"body":"Saves whether a user can access a particular exhibit into rethink and check permissions when the user hits the API.  Responds with 403 when the user isn't allowed in.\r\n\r\nI chose to do the rethink stuff a bit differently here than in the `quantifiedSelf` repo.  I made a `dbhelper` file that does all of the heavy rethink stuff and you just create a new object that inherits from that and implements all of the logic.  The only annoying part is the accessor function that maintains the global connection, but there's no real way around that.  I think doing it this was will make it easier for each processor to deal with it's own rethink connection, if that processor needs an actual DB.\r\n\r\nNOTE: the permissions stuff (as well as the checkin stuff) will use the `gulperbase` db... if a processor is making it's own connection to the DB it should have it's own DB.  Remember, the end goal is to have every process be isolated and working on it's own machine.","created_at":"2016-04-09T23:54:17Z","updated_at":"2016-04-10T00:46:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b6e0844c66505053d8cb9b0c468e9b70271bbf6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22/commits","review_comments_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22/comments","review_comment_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/22/comments","statuses_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/statuses/a439049e54537b504ecba4c9dd76b99222004b5e","head":{"label":"QuantifiedSelfless:exhibit_permissions","ref":"exhibit_permissions","sha":"a439049e54537b504ecba4c9dd76b99222004b5e","user":{"login":"QuantifiedSelfless","id":15035985,"avatar_url":"https://avatars.githubusercontent.com/u/15035985?v=3","gravatar_id":"","url":"https://api.github.com/users/QuantifiedSelfless","html_url":"https://github.com/QuantifiedSelfless","followers_url":"https://api.github.com/users/QuantifiedSelfless/followers","following_url":"https://api.github.com/users/QuantifiedSelfless/following{/other_user}","gists_url":"https://api.github.com/users/QuantifiedSelfless/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantifiedSelfless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantifiedSelfless/subscriptions","organizations_url":"https://api.github.com/users/QuantifiedSelfless/orgs","repos_url":"https://api.github.com/users/QuantifiedSelfless/repos","events_url":"https://api.github.com/users/QuantifiedSelfless/events{/privacy}","received_events_url":"https://api.github.com/users/QuantifiedSelfless/received_events","type":"Organization","site_admin":false},"repo":{"id":51622435,"name":"gulper","full_name":"QuantifiedSelfless/gulper","owner":{"login":"QuantifiedSelfless","id":15035985,"avatar_url":"https://avatars.githubusercontent.com/u/15035985?v=3","gravatar_id":"","url":"https://api.github.com/users/QuantifiedSelfless","html_url":"https://github.com/QuantifiedSelfless","followers_url":"https://api.github.com/users/QuantifiedSelfless/followers","following_url":"https://api.github.com/users/QuantifiedSelfless/following{/other_user}","gists_url":"https://api.github.com/users/QuantifiedSelfless/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantifiedSelfless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantifiedSelfless/subscriptions","organizations_url":"https://api.github.com/users/QuantifiedSelfless/orgs","repos_url":"https://api.github.com/users/QuantifiedSelfless/repos","events_url":"https://api.github.com/users/QuantifiedSelfless/events{/privacy}","received_events_url":"https://api.github.com/users/QuantifiedSelfless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QuantifiedSelfless/gulper","description":"data ingestion","fork":false,"url":"https://api.github.com/repos/QuantifiedSelfless/gulper","forks_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/forks","keys_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/teams","hooks_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/hooks","issue_events_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/events{/number}","events_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/events","assignees_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/assignees{/user}","branches_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/branches{/branch}","tags_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/tags","blobs_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/refs{/sha}","trees_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/statuses/{sha}","languages_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/languages","stargazers_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/stargazers","contributors_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/contributors","subscribers_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/subscribers","subscription_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/subscription","commits_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/commits{/sha}","git_commits_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/commits{/sha}","comments_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/comments{/number}","issue_comment_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/comments{/number}","contents_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/contents/{+path}","compare_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/merges","archive_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/downloads","issues_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues{/number}","pulls_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls{/number}","milestones_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/milestones{/number}","notifications_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/labels{/name}","releases_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/releases{/id}","deployments_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/deployments","created_at":"2016-02-12T23:07:20Z","updated_at":"2016-04-04T23:23:31Z","pushed_at":"2016-04-10T00:44:31Z","git_url":"git://github.com/QuantifiedSelfless/gulper.git","ssh_url":"git@github.com:QuantifiedSelfless/gulper.git","clone_url":"https://github.com/QuantifiedSelfless/gulper.git","svn_url":"https://github.com/QuantifiedSelfless/gulper","homepage":null,"size":136,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"base":{"label":"QuantifiedSelfless:master","ref":"master","sha":"364fefcffbcf3a82f63d0ca96af38f58acfc7bd2","user":{"login":"QuantifiedSelfless","id":15035985,"avatar_url":"https://avatars.githubusercontent.com/u/15035985?v=3","gravatar_id":"","url":"https://api.github.com/users/QuantifiedSelfless","html_url":"https://github.com/QuantifiedSelfless","followers_url":"https://api.github.com/users/QuantifiedSelfless/followers","following_url":"https://api.github.com/users/QuantifiedSelfless/following{/other_user}","gists_url":"https://api.github.com/users/QuantifiedSelfless/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantifiedSelfless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantifiedSelfless/subscriptions","organizations_url":"https://api.github.com/users/QuantifiedSelfless/orgs","repos_url":"https://api.github.com/users/QuantifiedSelfless/repos","events_url":"https://api.github.com/users/QuantifiedSelfless/events{/privacy}","received_events_url":"https://api.github.com/users/QuantifiedSelfless/received_events","type":"Organization","site_admin":false},"repo":{"id":51622435,"name":"gulper","full_name":"QuantifiedSelfless/gulper","owner":{"login":"QuantifiedSelfless","id":15035985,"avatar_url":"https://avatars.githubusercontent.com/u/15035985?v=3","gravatar_id":"","url":"https://api.github.com/users/QuantifiedSelfless","html_url":"https://github.com/QuantifiedSelfless","followers_url":"https://api.github.com/users/QuantifiedSelfless/followers","following_url":"https://api.github.com/users/QuantifiedSelfless/following{/other_user}","gists_url":"https://api.github.com/users/QuantifiedSelfless/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantifiedSelfless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantifiedSelfless/subscriptions","organizations_url":"https://api.github.com/users/QuantifiedSelfless/orgs","repos_url":"https://api.github.com/users/QuantifiedSelfless/repos","events_url":"https://api.github.com/users/QuantifiedSelfless/events{/privacy}","received_events_url":"https://api.github.com/users/QuantifiedSelfless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QuantifiedSelfless/gulper","description":"data ingestion","fork":false,"url":"https://api.github.com/repos/QuantifiedSelfless/gulper","forks_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/forks","keys_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/teams","hooks_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/hooks","issue_events_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/events{/number}","events_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/events","assignees_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/assignees{/user}","branches_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/branches{/branch}","tags_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/tags","blobs_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/refs{/sha}","trees_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/statuses/{sha}","languages_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/languages","stargazers_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/stargazers","contributors_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/contributors","subscribers_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/subscribers","subscription_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/subscription","commits_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/commits{/sha}","git_commits_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/git/commits{/sha}","comments_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/comments{/number}","issue_comment_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/comments{/number}","contents_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/contents/{+path}","compare_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/merges","archive_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/downloads","issues_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues{/number}","pulls_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls{/number}","milestones_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/milestones{/number}","notifications_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/labels{/name}","releases_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/releases{/id}","deployments_url":"https://api.github.com/repos/QuantifiedSelfless/gulper/deployments","created_at":"2016-02-12T23:07:20Z","updated_at":"2016-04-04T23:23:31Z","pushed_at":"2016-04-10T00:44:31Z","git_url":"git://github.com/QuantifiedSelfless/gulper.git","ssh_url":"git@github.com:QuantifiedSelfless/gulper.git","clone_url":"https://github.com/QuantifiedSelfless/gulper.git","svn_url":"https://github.com/QuantifiedSelfless/gulper","homepage":null,"size":136,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22"},"html":{"href":"https://github.com/QuantifiedSelfless/gulper/pull/22"},"issue":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/22"},"comments":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/QuantifiedSelfless/gulper/statuses/a439049e54537b504ecba4c9dd76b99222004b5e"}}}}