{"action":"created","comment":{"url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/comments/39802918","id":39802918,"diff_hunk":"@@ -101,25 +100,26 @@ def patch(self, patch):\n         return self.__class__(data, model=model)\n \n     def commit(self):\n-        db.session.begin(subtransactions=True)\n         try:\n-            list(functions('recordext'))\n+            with db.session.begin_nested():\n+                list(functions('recordext'))\n+\n+                toposort_send(before_record_update, self)\n \n-            toposort_send(before_record_update, self)\n+                if self.model is None:\n+                    self.model = RecordMetadata.query.get(self['recid'])\n \n-            if self.model is None:\n-                self.model = RecordMetadata.query.get(self['recid'])\n+                self.model.json = dict(self)\n \n-            self.model.json = dict(self)\n+                db.session.add(self.model)","path":"invenio_records/api.py","position":63,"original_position":63,"commit_id":"cd1b4c19fb6a741b91c2d9eef541fb0c4c789d33","original_commit_id":"cd1b4c19fb6a741b91c2d9eef541fb0c4c789d33","user":{"login":"jirikuncar","id":189798,"avatar_url":"https://avatars.githubusercontent.com/u/189798?v=3","gravatar_id":"","url":"https://api.github.com/users/jirikuncar","html_url":"https://github.com/jirikuncar","followers_url":"https://api.github.com/users/jirikuncar/followers","following_url":"https://api.github.com/users/jirikuncar/following{/other_user}","gists_url":"https://api.github.com/users/jirikuncar/gists{/gist_id}","starred_url":"https://api.github.com/users/jirikuncar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jirikuncar/subscriptions","organizations_url":"https://api.github.com/users/jirikuncar/orgs","repos_url":"https://api.github.com/users/jirikuncar/repos","events_url":"https://api.github.com/users/jirikuncar/events{/privacy}","received_events_url":"https://api.github.com/users/jirikuncar/received_events","type":"User","site_admin":false},"body":"@egabancho shall we better use `db.session.merge` as the `model` can be already in session?","created_at":"2015-09-17T21:43:39Z","updated_at":"2015-09-17T21:43:39Z","html_url":"https://github.com/inveniosoftware/invenio-records/pull/38#discussion_r39802918","pull_request_url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38","_links":{"self":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/comments/39802918"},"html":{"href":"https://github.com/inveniosoftware/invenio-records/pull/38#discussion_r39802918"},"pull_request":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38","id":45301247,"html_url":"https://github.com/inveniosoftware/invenio-records/pull/38","diff_url":"https://github.com/inveniosoftware/invenio-records/pull/38.diff","patch_url":"https://github.com/inveniosoftware/invenio-records/pull/38.patch","issue_url":"https://api.github.com/repos/inveniosoftware/invenio-records/issues/38","number":38,"state":"open","locked":false,"title":"WIP api: usage of nested transactions instead of subtransactions","user":{"login":"egabancho","id":582735,"avatar_url":"https://avatars.githubusercontent.com/u/582735?v=3","gravatar_id":"","url":"https://api.github.com/users/egabancho","html_url":"https://github.com/egabancho","followers_url":"https://api.github.com/users/egabancho/followers","following_url":"https://api.github.com/users/egabancho/following{/other_user}","gists_url":"https://api.github.com/users/egabancho/gists{/gist_id}","starred_url":"https://api.github.com/users/egabancho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egabancho/subscriptions","organizations_url":"https://api.github.com/users/egabancho/orgs","repos_url":"https://api.github.com/users/egabancho/repos","events_url":"https://api.github.com/users/egabancho/events{/privacy}","received_events_url":"https://api.github.com/users/egabancho/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-17T15:03:10Z","updated_at":"2015-09-17T21:43:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1607baf5cc92fbf87a0f1f054ab6e624af8116dc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38/commits","review_comments_url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38/comments","review_comment_url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inveniosoftware/invenio-records/issues/38/comments","statuses_url":"https://api.github.com/repos/inveniosoftware/invenio-records/statuses/cd1b4c19fb6a741b91c2d9eef541fb0c4c789d33","head":{"label":"egabancho:create-replace-record","ref":"create-replace-record","sha":"cd1b4c19fb6a741b91c2d9eef541fb0c4c789d33","user":{"login":"egabancho","id":582735,"avatar_url":"https://avatars.githubusercontent.com/u/582735?v=3","gravatar_id":"","url":"https://api.github.com/users/egabancho","html_url":"https://github.com/egabancho","followers_url":"https://api.github.com/users/egabancho/followers","following_url":"https://api.github.com/users/egabancho/following{/other_user}","gists_url":"https://api.github.com/users/egabancho/gists{/gist_id}","starred_url":"https://api.github.com/users/egabancho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egabancho/subscriptions","organizations_url":"https://api.github.com/users/egabancho/orgs","repos_url":"https://api.github.com/users/egabancho/repos","events_url":"https://api.github.com/users/egabancho/events{/privacy}","received_events_url":"https://api.github.com/users/egabancho/received_events","type":"User","site_admin":false},"repo":{"id":38440240,"name":"invenio-records","full_name":"egabancho/invenio-records","owner":{"login":"egabancho","id":582735,"avatar_url":"https://avatars.githubusercontent.com/u/582735?v=3","gravatar_id":"","url":"https://api.github.com/users/egabancho","html_url":"https://github.com/egabancho","followers_url":"https://api.github.com/users/egabancho/followers","following_url":"https://api.github.com/users/egabancho/following{/other_user}","gists_url":"https://api.github.com/users/egabancho/gists{/gist_id}","starred_url":"https://api.github.com/users/egabancho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egabancho/subscriptions","organizations_url":"https://api.github.com/users/egabancho/orgs","repos_url":"https://api.github.com/users/egabancho/repos","events_url":"https://api.github.com/users/egabancho/events{/privacy}","received_events_url":"https://api.github.com/users/egabancho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/egabancho/invenio-records","description":"Invenio Record API.","fork":true,"url":"https://api.github.com/repos/egabancho/invenio-records","forks_url":"https://api.github.com/repos/egabancho/invenio-records/forks","keys_url":"https://api.github.com/repos/egabancho/invenio-records/keys{/key_id}","collaborators_url":"https://api.github.com/repos/egabancho/invenio-records/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/egabancho/invenio-records/teams","hooks_url":"https://api.github.com/repos/egabancho/invenio-records/hooks","issue_events_url":"https://api.github.com/repos/egabancho/invenio-records/issues/events{/number}","events_url":"https://api.github.com/repos/egabancho/invenio-records/events","assignees_url":"https://api.github.com/repos/egabancho/invenio-records/assignees{/user}","branches_url":"https://api.github.com/repos/egabancho/invenio-records/branches{/branch}","tags_url":"https://api.github.com/repos/egabancho/invenio-records/tags","blobs_url":"https://api.github.com/repos/egabancho/invenio-records/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/egabancho/invenio-records/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/egabancho/invenio-records/git/refs{/sha}","trees_url":"https://api.github.com/repos/egabancho/invenio-records/git/trees{/sha}","statuses_url":"https://api.github.com/repos/egabancho/invenio-records/statuses/{sha}","languages_url":"https://api.github.com/repos/egabancho/invenio-records/languages","stargazers_url":"https://api.github.com/repos/egabancho/invenio-records/stargazers","contributors_url":"https://api.github.com/repos/egabancho/invenio-records/contributors","subscribers_url":"https://api.github.com/repos/egabancho/invenio-records/subscribers","subscription_url":"https://api.github.com/repos/egabancho/invenio-records/subscription","commits_url":"https://api.github.com/repos/egabancho/invenio-records/commits{/sha}","git_commits_url":"https://api.github.com/repos/egabancho/invenio-records/git/commits{/sha}","comments_url":"https://api.github.com/repos/egabancho/invenio-records/comments{/number}","issue_comment_url":"https://api.github.com/repos/egabancho/invenio-records/issues/comments{/number}","contents_url":"https://api.github.com/repos/egabancho/invenio-records/contents/{+path}","compare_url":"https://api.github.com/repos/egabancho/invenio-records/compare/{base}...{head}","merges_url":"https://api.github.com/repos/egabancho/invenio-records/merges","archive_url":"https://api.github.com/repos/egabancho/invenio-records/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/egabancho/invenio-records/downloads","issues_url":"https://api.github.com/repos/egabancho/invenio-records/issues{/number}","pulls_url":"https://api.github.com/repos/egabancho/invenio-records/pulls{/number}","milestones_url":"https://api.github.com/repos/egabancho/invenio-records/milestones{/number}","notifications_url":"https://api.github.com/repos/egabancho/invenio-records/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/egabancho/invenio-records/labels{/name}","releases_url":"https://api.github.com/repos/egabancho/invenio-records/releases{/id}","created_at":"2015-07-02T15:18:05Z","updated_at":"2015-07-02T15:18:05Z","pushed_at":"2015-09-17T15:28:12Z","git_url":"git://github.com/egabancho/invenio-records.git","ssh_url":"git@github.com:egabancho/invenio-records.git","clone_url":"https://github.com/egabancho/invenio-records.git","svn_url":"https://github.com/egabancho/invenio-records","homepage":"","size":3551,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"inveniosoftware:master","ref":"master","sha":"72a3767b86552ee3c7af5aefc9cf8f980d593850","user":{"login":"inveniosoftware","id":1157480,"avatar_url":"https://avatars.githubusercontent.com/u/1157480?v=3","gravatar_id":"","url":"https://api.github.com/users/inveniosoftware","html_url":"https://github.com/inveniosoftware","followers_url":"https://api.github.com/users/inveniosoftware/followers","following_url":"https://api.github.com/users/inveniosoftware/following{/other_user}","gists_url":"https://api.github.com/users/inveniosoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/inveniosoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inveniosoftware/subscriptions","organizations_url":"https://api.github.com/users/inveniosoftware/orgs","repos_url":"https://api.github.com/users/inveniosoftware/repos","events_url":"https://api.github.com/users/inveniosoftware/events{/privacy}","received_events_url":"https://api.github.com/users/inveniosoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":37462194,"name":"invenio-records","full_name":"inveniosoftware/invenio-records","owner":{"login":"inveniosoftware","id":1157480,"avatar_url":"https://avatars.githubusercontent.com/u/1157480?v=3","gravatar_id":"","url":"https://api.github.com/users/inveniosoftware","html_url":"https://github.com/inveniosoftware","followers_url":"https://api.github.com/users/inveniosoftware/followers","following_url":"https://api.github.com/users/inveniosoftware/following{/other_user}","gists_url":"https://api.github.com/users/inveniosoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/inveniosoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inveniosoftware/subscriptions","organizations_url":"https://api.github.com/users/inveniosoftware/orgs","repos_url":"https://api.github.com/users/inveniosoftware/repos","events_url":"https://api.github.com/users/inveniosoftware/events{/privacy}","received_events_url":"https://api.github.com/users/inveniosoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inveniosoftware/invenio-records","description":"Invenio-Record Metadata Storage Module","fork":false,"url":"https://api.github.com/repos/inveniosoftware/invenio-records","forks_url":"https://api.github.com/repos/inveniosoftware/invenio-records/forks","keys_url":"https://api.github.com/repos/inveniosoftware/invenio-records/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inveniosoftware/invenio-records/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inveniosoftware/invenio-records/teams","hooks_url":"https://api.github.com/repos/inveniosoftware/invenio-records/hooks","issue_events_url":"https://api.github.com/repos/inveniosoftware/invenio-records/issues/events{/number}","events_url":"https://api.github.com/repos/inveniosoftware/invenio-records/events","assignees_url":"https://api.github.com/repos/inveniosoftware/invenio-records/assignees{/user}","branches_url":"https://api.github.com/repos/inveniosoftware/invenio-records/branches{/branch}","tags_url":"https://api.github.com/repos/inveniosoftware/invenio-records/tags","blobs_url":"https://api.github.com/repos/inveniosoftware/invenio-records/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inveniosoftware/invenio-records/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inveniosoftware/invenio-records/git/refs{/sha}","trees_url":"https://api.github.com/repos/inveniosoftware/invenio-records/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inveniosoftware/invenio-records/statuses/{sha}","languages_url":"https://api.github.com/repos/inveniosoftware/invenio-records/languages","stargazers_url":"https://api.github.com/repos/inveniosoftware/invenio-records/stargazers","contributors_url":"https://api.github.com/repos/inveniosoftware/invenio-records/contributors","subscribers_url":"https://api.github.com/repos/inveniosoftware/invenio-records/subscribers","subscription_url":"https://api.github.com/repos/inveniosoftware/invenio-records/subscription","commits_url":"https://api.github.com/repos/inveniosoftware/invenio-records/commits{/sha}","git_commits_url":"https://api.github.com/repos/inveniosoftware/invenio-records/git/commits{/sha}","comments_url":"https://api.github.com/repos/inveniosoftware/invenio-records/comments{/number}","issue_comment_url":"https://api.github.com/repos/inveniosoftware/invenio-records/issues/comments{/number}","contents_url":"https://api.github.com/repos/inveniosoftware/invenio-records/contents/{+path}","compare_url":"https://api.github.com/repos/inveniosoftware/invenio-records/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inveniosoftware/invenio-records/merges","archive_url":"https://api.github.com/repos/inveniosoftware/invenio-records/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inveniosoftware/invenio-records/downloads","issues_url":"https://api.github.com/repos/inveniosoftware/invenio-records/issues{/number}","pulls_url":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls{/number}","milestones_url":"https://api.github.com/repos/inveniosoftware/invenio-records/milestones{/number}","notifications_url":"https://api.github.com/repos/inveniosoftware/invenio-records/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inveniosoftware/invenio-records/labels{/name}","releases_url":"https://api.github.com/repos/inveniosoftware/invenio-records/releases{/id}","created_at":"2015-06-15T11:55:19Z","updated_at":"2015-07-03T17:33:37Z","pushed_at":"2015-09-17T15:28:13Z","git_url":"git://github.com/inveniosoftware/invenio-records.git","ssh_url":"git@github.com:inveniosoftware/invenio-records.git","clone_url":"https://github.com/inveniosoftware/invenio-records.git","svn_url":"https://github.com/inveniosoftware/invenio-records","homepage":"","size":3850,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":12,"forks":15,"open_issues":12,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38"},"html":{"href":"https://github.com/inveniosoftware/invenio-records/pull/38"},"issue":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/issues/38"},"comments":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/inveniosoftware/invenio-records/statuses/cd1b4c19fb6a741b91c2d9eef541fb0c4c789d33"}}}}