{"action":"created","comment":{"url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/comments/33878819","id":33878819,"diff_hunk":"@@ -0,0 +1,214 @@\n+# -*- coding: utf-8 -*-\n+from __future__ import unicode_literals\n+import datetime\n+import os\n+\n+from cryptacular.bcrypt import BCRYPTPasswordManager\n+from pyramid.authentication import AuthTktAuthenticationPolicy\n+from pyramid.authorization import ACLAuthorizationPolicy\n+from pyramid.config import Configurator\n+from pyramid.httpexceptions import HTTPFound, HTTPNotFound\n+from pyramid.security import remember, forget\n+from pyramid.view import view_config\n+import sqlalchemy as sa\n+from sqlalchemy.exc import DBAPIError\n+from sqlalchemy.ext.declarative import declarative_base\n+from sqlalchemy.orm import scoped_session, sessionmaker\n+from waitress import serve\n+from zope.sqlalchemy import ZopeTransactionExtension\n+\n+HERE = os.path.dirname(os.path.abspath(__file__))\n+\n+DATABASE_URL = os.environ.get(\n+    'DATABASE_URL',\n+    'postgresql://jonathan@localhost:5432/learning-journal'\n+)\n+\n+DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))\n+\n+Base = declarative_base()\n+\n+\n+class Entry(Base):\n+    __tablename__ = \"entries\"\n+\n+    id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)\n+    title = sa.Column(sa.Unicode(127), nullable=False)\n+    text = sa.Column(sa.UnicodeText, nullable=False)\n+    created = sa.Column(\n+        sa.DateTime, nullable=False, default=datetime.datetime.utcnow\n+    )\n+\n+    def __repr__(self):\n+        return \"Entry: {title} created at {date}\".format(\n+            title=self.title, date=self.created\n+        )\n+\n+    @classmethod\n+    def all(cls, session=None):\n+        if session is None:\n+            session = DBSession\n+        return session.query(cls).order_by(cls.created.desc()).all()\n+\n+    @classmethod\n+    def by_id(cls, id_, session=None):\n+        if session is None:\n+            session = DBSession\n+        return session.query(cls).filter(cls.id == id_).first()\n+\n+    @classmethod\n+    def write(cls, title=None, text=None, session=None):\n+        if session is None:\n+            session = DBSession\n+        instance = cls(title=title, text=text)\n+        session.add(instance)\n+        return instance\n+\n+\n+def init_db():\n+    engine = sa.create_engine(DATABASE_URL, echo=False)\n+    Base.metadata.create_all(engine)\n+\n+\n+def do_login(request):\n+    username = request.params.get('username', None)\n+    password = request.params.get('password', None)\n+    if not (username and password):\n+        raise ValueError('both username and password are required')\n+\n+    settings = request.registry.settings\n+    manager = BCRYPTPasswordManager()\n+    if username == settings.get('auth.username', ''):\n+        hashed = settings.get('auth.password', '')\n+        return manager.check(hashed, password)\n+    return False\n+\n+\n+@view_config(route_name='home', renderer='templates/list.jinja2')\n+def list_view(request):\n+    entries = Entry.all()\n+    return {'entries': entries}\n+\n+\n+@view_config(route_name='about', renderer='templates/about.jinja2')\n+def about_view(request):\n+    return {}\n+\n+\n+@view_config(route_name='detail', renderer='templates/detail.jinja2')\n+def detail_view(request):\n+    entry_id = int(request.matchdict.get('id', -1))\n+    entry = Entry.by_id(entry_id)\n+    if entry is None:\n+        return HTTPNotFound()\n+    return {'entry': entry}","path":"journal.py","position":104,"original_position":104,"commit_id":"070cbc0c0766d2f229b11f9dda1b6aa76f15821e","original_commit_id":"070cbc0c0766d2f229b11f9dda1b6aa76f15821e","user":{"login":"cewing","id":417109,"avatar_url":"https://avatars.githubusercontent.com/u/417109?v=3","gravatar_id":"","url":"https://api.github.com/users/cewing","html_url":"https://github.com/cewing","followers_url":"https://api.github.com/users/cewing/followers","following_url":"https://api.github.com/users/cewing/following{/other_user}","gists_url":"https://api.github.com/users/cewing/gists{/gist_id}","starred_url":"https://api.github.com/users/cewing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cewing/subscriptions","organizations_url":"https://api.github.com/users/cewing/orgs","repos_url":"https://api.github.com/users/cewing/repos","events_url":"https://api.github.com/users/cewing/events{/privacy}","received_events_url":"https://api.github.com/users/cewing/received_events","type":"User","site_admin":false},"body":"good.  ","created_at":"2015-07-03T19:39:05Z","updated_at":"2015-07-03T19:39:05Z","html_url":"https://github.com/jonathanstallings/learning-journal/pull/5#discussion_r33878819","pull_request_url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/comments/33878819"},"html":{"href":"https://github.com/jonathanstallings/learning-journal/pull/5#discussion_r33878819"},"pull_request":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5","id":38971153,"html_url":"https://github.com/jonathanstallings/learning-journal/pull/5","diff_url":"https://github.com/jonathanstallings/learning-journal/pull/5.diff","patch_url":"https://github.com/jonathanstallings/learning-journal/pull/5.patch","issue_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/5","number":5,"state":"open","locked":false,"title":"Comparing to project start. *DO NOT MERGE*","user":{"login":"jonathanstallings","id":10945369,"avatar_url":"https://avatars.githubusercontent.com/u/10945369?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanstallings","html_url":"https://github.com/jonathanstallings","followers_url":"https://api.github.com/users/jonathanstallings/followers","following_url":"https://api.github.com/users/jonathanstallings/following{/other_user}","gists_url":"https://api.github.com/users/jonathanstallings/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanstallings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanstallings/subscriptions","organizations_url":"https://api.github.com/users/jonathanstallings/orgs","repos_url":"https://api.github.com/users/jonathanstallings/repos","events_url":"https://api.github.com/users/jonathanstallings/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanstallings/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-01T11:08:09Z","updated_at":"2015-07-03T19:39:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73dde13dff18a32ab331581cc58bb9cf84226e6a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5/commits","review_comments_url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5/comments","review_comment_url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/5/comments","statuses_url":"https://api.github.com/repos/jonathanstallings/learning-journal/statuses/070cbc0c0766d2f229b11f9dda1b6aa76f15821e","head":{"label":"jonathanstallings:master","ref":"master","sha":"070cbc0c0766d2f229b11f9dda1b6aa76f15821e","user":{"login":"jonathanstallings","id":10945369,"avatar_url":"https://avatars.githubusercontent.com/u/10945369?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanstallings","html_url":"https://github.com/jonathanstallings","followers_url":"https://api.github.com/users/jonathanstallings/followers","following_url":"https://api.github.com/users/jonathanstallings/following{/other_user}","gists_url":"https://api.github.com/users/jonathanstallings/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanstallings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanstallings/subscriptions","organizations_url":"https://api.github.com/users/jonathanstallings/orgs","repos_url":"https://api.github.com/users/jonathanstallings/repos","events_url":"https://api.github.com/users/jonathanstallings/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanstallings/received_events","type":"User","site_admin":false},"repo":{"id":37489175,"name":"learning-journal","full_name":"jonathanstallings/learning-journal","owner":{"login":"jonathanstallings","id":10945369,"avatar_url":"https://avatars.githubusercontent.com/u/10945369?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanstallings","html_url":"https://github.com/jonathanstallings","followers_url":"https://api.github.com/users/jonathanstallings/followers","following_url":"https://api.github.com/users/jonathanstallings/following{/other_user}","gists_url":"https://api.github.com/users/jonathanstallings/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanstallings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanstallings/subscriptions","organizations_url":"https://api.github.com/users/jonathanstallings/orgs","repos_url":"https://api.github.com/users/jonathanstallings/repos","events_url":"https://api.github.com/users/jonathanstallings/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanstallings/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonathanstallings/learning-journal","description":"A simple learning journal mockup","fork":false,"url":"https://api.github.com/repos/jonathanstallings/learning-journal","forks_url":"https://api.github.com/repos/jonathanstallings/learning-journal/forks","keys_url":"https://api.github.com/repos/jonathanstallings/learning-journal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonathanstallings/learning-journal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonathanstallings/learning-journal/teams","hooks_url":"https://api.github.com/repos/jonathanstallings/learning-journal/hooks","issue_events_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/events{/number}","events_url":"https://api.github.com/repos/jonathanstallings/learning-journal/events","assignees_url":"https://api.github.com/repos/jonathanstallings/learning-journal/assignees{/user}","branches_url":"https://api.github.com/repos/jonathanstallings/learning-journal/branches{/branch}","tags_url":"https://api.github.com/repos/jonathanstallings/learning-journal/tags","blobs_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonathanstallings/learning-journal/statuses/{sha}","languages_url":"https://api.github.com/repos/jonathanstallings/learning-journal/languages","stargazers_url":"https://api.github.com/repos/jonathanstallings/learning-journal/stargazers","contributors_url":"https://api.github.com/repos/jonathanstallings/learning-journal/contributors","subscribers_url":"https://api.github.com/repos/jonathanstallings/learning-journal/subscribers","subscription_url":"https://api.github.com/repos/jonathanstallings/learning-journal/subscription","commits_url":"https://api.github.com/repos/jonathanstallings/learning-journal/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonathanstallings/learning-journal/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonathanstallings/learning-journal/contents/{+path}","compare_url":"https://api.github.com/repos/jonathanstallings/learning-journal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonathanstallings/learning-journal/merges","archive_url":"https://api.github.com/repos/jonathanstallings/learning-journal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonathanstallings/learning-journal/downloads","issues_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues{/number}","pulls_url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls{/number}","milestones_url":"https://api.github.com/repos/jonathanstallings/learning-journal/milestones{/number}","notifications_url":"https://api.github.com/repos/jonathanstallings/learning-journal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonathanstallings/learning-journal/labels{/name}","releases_url":"https://api.github.com/repos/jonathanstallings/learning-journal/releases{/id}","created_at":"2015-06-15T20:20:45Z","updated_at":"2015-06-18T20:06:56Z","pushed_at":"2015-07-03T18:48:16Z","git_url":"git://github.com/jonathanstallings/learning-journal.git","ssh_url":"git@github.com:jonathanstallings/learning-journal.git","clone_url":"https://github.com/jonathanstallings/learning-journal.git","svn_url":"https://github.com/jonathanstallings/learning-journal","homepage":"","size":292,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"jonathanstallings:start","ref":"start","sha":"bf2aff758b41f4539fa0fbec0ad3dfb63cf339ca","user":{"login":"jonathanstallings","id":10945369,"avatar_url":"https://avatars.githubusercontent.com/u/10945369?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanstallings","html_url":"https://github.com/jonathanstallings","followers_url":"https://api.github.com/users/jonathanstallings/followers","following_url":"https://api.github.com/users/jonathanstallings/following{/other_user}","gists_url":"https://api.github.com/users/jonathanstallings/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanstallings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanstallings/subscriptions","organizations_url":"https://api.github.com/users/jonathanstallings/orgs","repos_url":"https://api.github.com/users/jonathanstallings/repos","events_url":"https://api.github.com/users/jonathanstallings/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanstallings/received_events","type":"User","site_admin":false},"repo":{"id":37489175,"name":"learning-journal","full_name":"jonathanstallings/learning-journal","owner":{"login":"jonathanstallings","id":10945369,"avatar_url":"https://avatars.githubusercontent.com/u/10945369?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanstallings","html_url":"https://github.com/jonathanstallings","followers_url":"https://api.github.com/users/jonathanstallings/followers","following_url":"https://api.github.com/users/jonathanstallings/following{/other_user}","gists_url":"https://api.github.com/users/jonathanstallings/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanstallings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanstallings/subscriptions","organizations_url":"https://api.github.com/users/jonathanstallings/orgs","repos_url":"https://api.github.com/users/jonathanstallings/repos","events_url":"https://api.github.com/users/jonathanstallings/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanstallings/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonathanstallings/learning-journal","description":"A simple learning journal mockup","fork":false,"url":"https://api.github.com/repos/jonathanstallings/learning-journal","forks_url":"https://api.github.com/repos/jonathanstallings/learning-journal/forks","keys_url":"https://api.github.com/repos/jonathanstallings/learning-journal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonathanstallings/learning-journal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonathanstallings/learning-journal/teams","hooks_url":"https://api.github.com/repos/jonathanstallings/learning-journal/hooks","issue_events_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/events{/number}","events_url":"https://api.github.com/repos/jonathanstallings/learning-journal/events","assignees_url":"https://api.github.com/repos/jonathanstallings/learning-journal/assignees{/user}","branches_url":"https://api.github.com/repos/jonathanstallings/learning-journal/branches{/branch}","tags_url":"https://api.github.com/repos/jonathanstallings/learning-journal/tags","blobs_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonathanstallings/learning-journal/statuses/{sha}","languages_url":"https://api.github.com/repos/jonathanstallings/learning-journal/languages","stargazers_url":"https://api.github.com/repos/jonathanstallings/learning-journal/stargazers","contributors_url":"https://api.github.com/repos/jonathanstallings/learning-journal/contributors","subscribers_url":"https://api.github.com/repos/jonathanstallings/learning-journal/subscribers","subscription_url":"https://api.github.com/repos/jonathanstallings/learning-journal/subscription","commits_url":"https://api.github.com/repos/jonathanstallings/learning-journal/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonathanstallings/learning-journal/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonathanstallings/learning-journal/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonathanstallings/learning-journal/contents/{+path}","compare_url":"https://api.github.com/repos/jonathanstallings/learning-journal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonathanstallings/learning-journal/merges","archive_url":"https://api.github.com/repos/jonathanstallings/learning-journal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonathanstallings/learning-journal/downloads","issues_url":"https://api.github.com/repos/jonathanstallings/learning-journal/issues{/number}","pulls_url":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls{/number}","milestones_url":"https://api.github.com/repos/jonathanstallings/learning-journal/milestones{/number}","notifications_url":"https://api.github.com/repos/jonathanstallings/learning-journal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonathanstallings/learning-journal/labels{/name}","releases_url":"https://api.github.com/repos/jonathanstallings/learning-journal/releases{/id}","created_at":"2015-06-15T20:20:45Z","updated_at":"2015-06-18T20:06:56Z","pushed_at":"2015-07-03T18:48:16Z","git_url":"git://github.com/jonathanstallings/learning-journal.git","ssh_url":"git@github.com:jonathanstallings/learning-journal.git","clone_url":"https://github.com/jonathanstallings/learning-journal.git","svn_url":"https://github.com/jonathanstallings/learning-journal","homepage":"","size":292,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5"},"html":{"href":"https://github.com/jonathanstallings/learning-journal/pull/5"},"issue":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/5"},"comments":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/jonathanstallings/learning-journal/statuses/070cbc0c0766d2f229b11f9dda1b6aa76f15821e"}}}}