{"action":"created","comment":{"url":"https://api.github.com/repos/alexsavinov/hello-world/pulls/comments/61716639","id":61716639,"diff_hunk":"@@ -0,0 +1,102 @@\n+from flask import current_app, Blueprint, render_template, abort, request, url_for, flash, redirect\r\n+from jinja2 import TemplateNotFound\r\n+from .forms import AddForm\r\n+from sqlalchemy import create_engine, Column, Integer, String, func\r\n+from sqlalchemy.ext.declarative import declarative_base\r\n+from sqlalchemy.orm import sessionmaker\r\n+\r\n+main_page = Blueprint('mainpage ', __name__)\r\n+\r\n+# init database\r\n+engine = create_engine('sqlite:///books.db', echo=False)\r\n+Base = declarative_base()\r\n+Session = sessionmaker(bind=engine)\r\n+session = Session()\r\n+\r\n+class Book(Base):\r\n+    __tablename__ = 'books'\r\n+\r\n+    id = Column(Integer, primary_key=True)\r\n+    name = Column(String)\r\n+    author = Column(String)\r\n+    pages = Column(Integer)\r\n+\r\n+    def __repr__(self):\r\n+        return \"<Book(name='%s', author='%s', pages='%s')>\" % (\r\n+                            self.name, self.author, self.pages)\r\n+\r\n+Base.metadata.create_all(engine)\r\n+\r\n+def update_books(book, action=''):\r\n+    if action == 'delete':\r\n+        session.delete(book)\r\n+    elif action == 'add':\r\n+        session.add(book)\r\n+    session.commit()\r","path":"app/views.py","position":35,"original_position":35,"commit_id":"b260131950d673db9752b10336a94d278740af23","original_commit_id":"b260131950d673db9752b10336a94d278740af23","user":{"login":"olegpidsadnyi","id":2608181,"avatar_url":"https://avatars.githubusercontent.com/u/2608181?v=3","gravatar_id":"","url":"https://api.github.com/users/olegpidsadnyi","html_url":"https://github.com/olegpidsadnyi","followers_url":"https://api.github.com/users/olegpidsadnyi/followers","following_url":"https://api.github.com/users/olegpidsadnyi/following{/other_user}","gists_url":"https://api.github.com/users/olegpidsadnyi/gists{/gist_id}","starred_url":"https://api.github.com/users/olegpidsadnyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olegpidsadnyi/subscriptions","organizations_url":"https://api.github.com/users/olegpidsadnyi/orgs","repos_url":"https://api.github.com/users/olegpidsadnyi/repos","events_url":"https://api.github.com/users/olegpidsadnyi/events{/privacy}","received_events_url":"https://api.github.com/users/olegpidsadnyi/received_events","type":"User","site_admin":false},"body":"Does flask-sqlachemy have hooks to commit/rollback? Normally you don't commit your sessions in the WSGI apps, because there's a request teardown phase where you either commit either rollback on the error.","created_at":"2016-05-02T08:53:10Z","updated_at":"2016-05-02T08:53:10Z","html_url":"https://github.com/alexsavinov/hello-world/pull/2#discussion_r61716639","pull_request_url":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/alexsavinov/hello-world/pulls/comments/61716639"},"html":{"href":"https://github.com/alexsavinov/hello-world/pull/2#discussion_r61716639"},"pull_request":{"href":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2","id":68376737,"html_url":"https://github.com/alexsavinov/hello-world/pull/2","diff_url":"https://github.com/alexsavinov/hello-world/pull/2.diff","patch_url":"https://github.com/alexsavinov/hello-world/pull/2.patch","issue_url":"https://api.github.com/repos/alexsavinov/hello-world/issues/2","number":2,"state":"open","locked":false,"title":"Blueprint #1","user":{"login":"alexsavinov","id":18281333,"avatar_url":"https://avatars.githubusercontent.com/u/18281333?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsavinov","html_url":"https://github.com/alexsavinov","followers_url":"https://api.github.com/users/alexsavinov/followers","following_url":"https://api.github.com/users/alexsavinov/following{/other_user}","gists_url":"https://api.github.com/users/alexsavinov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsavinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsavinov/subscriptions","organizations_url":"https://api.github.com/users/alexsavinov/orgs","repos_url":"https://api.github.com/users/alexsavinov/repos","events_url":"https://api.github.com/users/alexsavinov/events{/privacy}","received_events_url":"https://api.github.com/users/alexsavinov/received_events","type":"User","site_admin":false},"body":"Application added. Please check.","created_at":"2016-04-29T14:05:59Z","updated_at":"2016-05-02T08:53:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5bbd3ac961c72e4b24a1d084941f66caab947809","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2/commits","review_comments_url":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2/comments","review_comment_url":"https://api.github.com/repos/alexsavinov/hello-world/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alexsavinov/hello-world/issues/2/comments","statuses_url":"https://api.github.com/repos/alexsavinov/hello-world/statuses/b260131950d673db9752b10336a94d278740af23","head":{"label":"alexsavinov:Blueprint-#1","ref":"Blueprint-#1","sha":"b260131950d673db9752b10336a94d278740af23","user":{"login":"alexsavinov","id":18281333,"avatar_url":"https://avatars.githubusercontent.com/u/18281333?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsavinov","html_url":"https://github.com/alexsavinov","followers_url":"https://api.github.com/users/alexsavinov/followers","following_url":"https://api.github.com/users/alexsavinov/following{/other_user}","gists_url":"https://api.github.com/users/alexsavinov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsavinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsavinov/subscriptions","organizations_url":"https://api.github.com/users/alexsavinov/orgs","repos_url":"https://api.github.com/users/alexsavinov/repos","events_url":"https://api.github.com/users/alexsavinov/events{/privacy}","received_events_url":"https://api.github.com/users/alexsavinov/received_events","type":"User","site_admin":false},"repo":{"id":55515317,"name":"hello-world","full_name":"alexsavinov/hello-world","owner":{"login":"alexsavinov","id":18281333,"avatar_url":"https://avatars.githubusercontent.com/u/18281333?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsavinov","html_url":"https://github.com/alexsavinov","followers_url":"https://api.github.com/users/alexsavinov/followers","following_url":"https://api.github.com/users/alexsavinov/following{/other_user}","gists_url":"https://api.github.com/users/alexsavinov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsavinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsavinov/subscriptions","organizations_url":"https://api.github.com/users/alexsavinov/orgs","repos_url":"https://api.github.com/users/alexsavinov/repos","events_url":"https://api.github.com/users/alexsavinov/events{/privacy}","received_events_url":"https://api.github.com/users/alexsavinov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexsavinov/hello-world","description":"some description here","fork":false,"url":"https://api.github.com/repos/alexsavinov/hello-world","forks_url":"https://api.github.com/repos/alexsavinov/hello-world/forks","keys_url":"https://api.github.com/repos/alexsavinov/hello-world/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexsavinov/hello-world/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexsavinov/hello-world/teams","hooks_url":"https://api.github.com/repos/alexsavinov/hello-world/hooks","issue_events_url":"https://api.github.com/repos/alexsavinov/hello-world/issues/events{/number}","events_url":"https://api.github.com/repos/alexsavinov/hello-world/events","assignees_url":"https://api.github.com/repos/alexsavinov/hello-world/assignees{/user}","branches_url":"https://api.github.com/repos/alexsavinov/hello-world/branches{/branch}","tags_url":"https://api.github.com/repos/alexsavinov/hello-world/tags","blobs_url":"https://api.github.com/repos/alexsavinov/hello-world/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexsavinov/hello-world/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexsavinov/hello-world/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexsavinov/hello-world/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexsavinov/hello-world/statuses/{sha}","languages_url":"https://api.github.com/repos/alexsavinov/hello-world/languages","stargazers_url":"https://api.github.com/repos/alexsavinov/hello-world/stargazers","contributors_url":"https://api.github.com/repos/alexsavinov/hello-world/contributors","subscribers_url":"https://api.github.com/repos/alexsavinov/hello-world/subscribers","subscription_url":"https://api.github.com/repos/alexsavinov/hello-world/subscription","commits_url":"https://api.github.com/repos/alexsavinov/hello-world/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexsavinov/hello-world/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexsavinov/hello-world/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexsavinov/hello-world/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexsavinov/hello-world/contents/{+path}","compare_url":"https://api.github.com/repos/alexsavinov/hello-world/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexsavinov/hello-world/merges","archive_url":"https://api.github.com/repos/alexsavinov/hello-world/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexsavinov/hello-world/downloads","issues_url":"https://api.github.com/repos/alexsavinov/hello-world/issues{/number}","pulls_url":"https://api.github.com/repos/alexsavinov/hello-world/pulls{/number}","milestones_url":"https://api.github.com/repos/alexsavinov/hello-world/milestones{/number}","notifications_url":"https://api.github.com/repos/alexsavinov/hello-world/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexsavinov/hello-world/labels{/name}","releases_url":"https://api.github.com/repos/alexsavinov/hello-world/releases{/id}","deployments_url":"https://api.github.com/repos/alexsavinov/hello-world/deployments","created_at":"2016-04-05T14:35:08Z","updated_at":"2016-04-06T10:38:14Z","pushed_at":"2016-04-29T14:06:00Z","git_url":"git://github.com/alexsavinov/hello-world.git","ssh_url":"git@github.com:alexsavinov/hello-world.git","clone_url":"https://github.com/alexsavinov/hello-world.git","svn_url":"https://github.com/alexsavinov/hello-world","homepage":null,"size":4,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"alexsavinov:master","ref":"master","sha":"ab66ce7aab22e3a713c2ca098a564a32afea56e0","user":{"login":"alexsavinov","id":18281333,"avatar_url":"https://avatars.githubusercontent.com/u/18281333?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsavinov","html_url":"https://github.com/alexsavinov","followers_url":"https://api.github.com/users/alexsavinov/followers","following_url":"https://api.github.com/users/alexsavinov/following{/other_user}","gists_url":"https://api.github.com/users/alexsavinov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsavinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsavinov/subscriptions","organizations_url":"https://api.github.com/users/alexsavinov/orgs","repos_url":"https://api.github.com/users/alexsavinov/repos","events_url":"https://api.github.com/users/alexsavinov/events{/privacy}","received_events_url":"https://api.github.com/users/alexsavinov/received_events","type":"User","site_admin":false},"repo":{"id":55515317,"name":"hello-world","full_name":"alexsavinov/hello-world","owner":{"login":"alexsavinov","id":18281333,"avatar_url":"https://avatars.githubusercontent.com/u/18281333?v=3","gravatar_id":"","url":"https://api.github.com/users/alexsavinov","html_url":"https://github.com/alexsavinov","followers_url":"https://api.github.com/users/alexsavinov/followers","following_url":"https://api.github.com/users/alexsavinov/following{/other_user}","gists_url":"https://api.github.com/users/alexsavinov/gists{/gist_id}","starred_url":"https://api.github.com/users/alexsavinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexsavinov/subscriptions","organizations_url":"https://api.github.com/users/alexsavinov/orgs","repos_url":"https://api.github.com/users/alexsavinov/repos","events_url":"https://api.github.com/users/alexsavinov/events{/privacy}","received_events_url":"https://api.github.com/users/alexsavinov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexsavinov/hello-world","description":"some description here","fork":false,"url":"https://api.github.com/repos/alexsavinov/hello-world","forks_url":"https://api.github.com/repos/alexsavinov/hello-world/forks","keys_url":"https://api.github.com/repos/alexsavinov/hello-world/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexsavinov/hello-world/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexsavinov/hello-world/teams","hooks_url":"https://api.github.com/repos/alexsavinov/hello-world/hooks","issue_events_url":"https://api.github.com/repos/alexsavinov/hello-world/issues/events{/number}","events_url":"https://api.github.com/repos/alexsavinov/hello-world/events","assignees_url":"https://api.github.com/repos/alexsavinov/hello-world/assignees{/user}","branches_url":"https://api.github.com/repos/alexsavinov/hello-world/branches{/branch}","tags_url":"https://api.github.com/repos/alexsavinov/hello-world/tags","blobs_url":"https://api.github.com/repos/alexsavinov/hello-world/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexsavinov/hello-world/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexsavinov/hello-world/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexsavinov/hello-world/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexsavinov/hello-world/statuses/{sha}","languages_url":"https://api.github.com/repos/alexsavinov/hello-world/languages","stargazers_url":"https://api.github.com/repos/alexsavinov/hello-world/stargazers","contributors_url":"https://api.github.com/repos/alexsavinov/hello-world/contributors","subscribers_url":"https://api.github.com/repos/alexsavinov/hello-world/subscribers","subscription_url":"https://api.github.com/repos/alexsavinov/hello-world/subscription","commits_url":"https://api.github.com/repos/alexsavinov/hello-world/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexsavinov/hello-world/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexsavinov/hello-world/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexsavinov/hello-world/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexsavinov/hello-world/contents/{+path}","compare_url":"https://api.github.com/repos/alexsavinov/hello-world/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexsavinov/hello-world/merges","archive_url":"https://api.github.com/repos/alexsavinov/hello-world/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexsavinov/hello-world/downloads","issues_url":"https://api.github.com/repos/alexsavinov/hello-world/issues{/number}","pulls_url":"https://api.github.com/repos/alexsavinov/hello-world/pulls{/number}","milestones_url":"https://api.github.com/repos/alexsavinov/hello-world/milestones{/number}","notifications_url":"https://api.github.com/repos/alexsavinov/hello-world/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexsavinov/hello-world/labels{/name}","releases_url":"https://api.github.com/repos/alexsavinov/hello-world/releases{/id}","deployments_url":"https://api.github.com/repos/alexsavinov/hello-world/deployments","created_at":"2016-04-05T14:35:08Z","updated_at":"2016-04-06T10:38:14Z","pushed_at":"2016-04-29T14:06:00Z","git_url":"git://github.com/alexsavinov/hello-world.git","ssh_url":"git@github.com:alexsavinov/hello-world.git","clone_url":"https://github.com/alexsavinov/hello-world.git","svn_url":"https://github.com/alexsavinov/hello-world","homepage":null,"size":4,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2"},"html":{"href":"https://github.com/alexsavinov/hello-world/pull/2"},"issue":{"href":"https://api.github.com/repos/alexsavinov/hello-world/issues/2"},"comments":{"href":"https://api.github.com/repos/alexsavinov/hello-world/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/alexsavinov/hello-world/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alexsavinov/hello-world/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/alexsavinov/hello-world/statuses/b260131950d673db9752b10336a94d278740af23"}}}}