{"action":"created","comment":{"url":"https://api.github.com/repos/inveniosoftware/invenio/pulls/comments/26740152","id":26740152,"diff_hunk":"@@ -0,0 +1,117 @@\n+from uuid import uuid4\n+\n+from sqlalchemy_utils import UUIDType\n+\n+from invenio.ext.sqlalchemy import db, utils\n+\n+\n+class SQLAlchemyNode(object):\n+\n+    \"\"\"TODO\"\"\"\n+\n+    def _edges(self, inwards=True, outwards=True, link_type=None):\n+        \"\"\"TODO\"\"\"\n+        query = SQLAlchemyEdge.query\n+\n+        if inwards and outwards:\n+            query = query.filter((SQLAlchemyEdge.id_to == self['_id']) |\n+                                 (SQLAlchemyEdge.id_from == self['_id']))","path":"invenio/modules/relationships/engines/sqlalchemy.py","position":18,"original_position":18,"commit_id":"06e97e4b0c608aedd45a1d67c2b19cfb4b1d3712","original_commit_id":"06e97e4b0c608aedd45a1d67c2b19cfb4b1d3712","user":{"login":"jacquerie","id":381280,"avatar_url":"https://avatars.githubusercontent.com/u/381280?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquerie","html_url":"https://github.com/jacquerie","followers_url":"https://api.github.com/users/jacquerie/followers","following_url":"https://api.github.com/users/jacquerie/following{/other_user}","gists_url":"https://api.github.com/users/jacquerie/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquerie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquerie/subscriptions","organizations_url":"https://api.github.com/users/jacquerie/orgs","repos_url":"https://api.github.com/users/jacquerie/repos","events_url":"https://api.github.com/users/jacquerie/events{/privacy}","received_events_url":"https://api.github.com/users/jacquerie/received_events","type":"User","site_admin":false},"body":"Yes, I should consider that. On the other hand, filtering by the appropriate `link_type` should yield the same result, since a specific `link_type` uniquely determines the `model_to` and `model_from` (or at least it does in the \"relationships octopus\" diagram we drew together).","created_at":"2015-03-19T09:45:45Z","updated_at":"2015-03-19T09:45:45Z","html_url":"https://github.com/inveniosoftware/invenio/pull/2903#discussion_r26740152","pull_request_url":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903","_links":{"self":{"href":"https://api.github.com/repos/inveniosoftware/invenio/pulls/comments/26740152"},"html":{"href":"https://github.com/inveniosoftware/invenio/pull/2903#discussion_r26740152"},"pull_request":{"href":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903"}}},"pull_request":{"url":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903","id":31449397,"html_url":"https://github.com/inveniosoftware/invenio/pull/2903","diff_url":"https://github.com/inveniosoftware/invenio/pull/2903.diff","patch_url":"https://github.com/inveniosoftware/invenio/pull/2903.patch","issue_url":"https://api.github.com/repos/inveniosoftware/invenio/issues/2903","number":2903,"state":"open","locked":false,"title":"WIP relationships: initial implementation","user":{"login":"jacquerie","id":381280,"avatar_url":"https://avatars.githubusercontent.com/u/381280?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquerie","html_url":"https://github.com/jacquerie","followers_url":"https://api.github.com/users/jacquerie/followers","following_url":"https://api.github.com/users/jacquerie/following{/other_user}","gists_url":"https://api.github.com/users/jacquerie/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquerie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquerie/subscriptions","organizations_url":"https://api.github.com/users/jacquerie/orgs","repos_url":"https://api.github.com/users/jacquerie/repos","events_url":"https://api.github.com/users/jacquerie/events{/privacy}","received_events_url":"https://api.github.com/users/jacquerie/received_events","type":"User","site_admin":false},"body":"I can (finally) show some of my work. I decided to abandon the approach outlined in #2823 and start anew; I actually ended up reusing a lot of @MSusik's code anyway.\r\n\r\nThe main idea is that the code is not using metaclasses, but simple inheritance; which class holds the actual implementation is dynamically decided by a few `import_string`s. The implementation still resides in `invenio/modules/relationships/engines/sqlalchemy.py`, and it's a bit simpler than the previous one.\r\n\r\nThe file `invenio/modules/relationships/testsuite/test_nodes.py` only shows that this inheritance mechanism is working, while the main API is tested in `invenio/modules/relationships/testsuite/test_edges.py`.\r\n\r\nI'm still missing a few things:\r\n\r\n* Testing that `annotations` have the `Node` behaviour, and perhaps some more classes.\r\n* Documenting, licensing and commenting the whole thing.\r\n\r\n(CC: @kaplun @jalavik)\r\n\r\n[skip ci]","created_at":"2015-03-18T17:00:29Z","updated_at":"2015-03-19T09:45:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27cf801f7033c4f1441255d7b3ea665fcc1a78ed","assignee":null,"milestone":{"url":"https://api.github.com/repos/inveniosoftware/invenio/milestones/13","html_url":"https://github.com/inveniosoftware/invenio/milestones/v2.1","labels_url":"https://api.github.com/repos/inveniosoftware/invenio/milestones/13/labels","id":857114,"number":13,"title":"v2.1","description":"","creator":{"login":"tiborsimko","id":517546,"avatar_url":"https://avatars.githubusercontent.com/u/517546?v=3","gravatar_id":"","url":"https://api.github.com/users/tiborsimko","html_url":"https://github.com/tiborsimko","followers_url":"https://api.github.com/users/tiborsimko/followers","following_url":"https://api.github.com/users/tiborsimko/following{/other_user}","gists_url":"https://api.github.com/users/tiborsimko/gists{/gist_id}","starred_url":"https://api.github.com/users/tiborsimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiborsimko/subscriptions","organizations_url":"https://api.github.com/users/tiborsimko/orgs","repos_url":"https://api.github.com/users/tiborsimko/repos","events_url":"https://api.github.com/users/tiborsimko/events{/privacy}","received_events_url":"https://api.github.com/users/tiborsimko/received_events","type":"User","site_admin":false},"open_issues":48,"closed_issues":16,"state":"open","created_at":"2014-11-07T09:21:23Z","updated_at":"2015-03-19T08:27:55Z","due_on":"2015-04-30T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903/commits","review_comments_url":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903/comments","review_comment_url":"https://api.github.com/repos/inveniosoftware/invenio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inveniosoftware/invenio/issues/2903/comments","statuses_url":"https://api.github.com/repos/inveniosoftware/invenio/statuses/06e97e4b0c608aedd45a1d67c2b19cfb4b1d3712","head":{"label":"jacquerie:add-relationships","ref":"add-relationships","sha":"06e97e4b0c608aedd45a1d67c2b19cfb4b1d3712","user":{"login":"jacquerie","id":381280,"avatar_url":"https://avatars.githubusercontent.com/u/381280?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquerie","html_url":"https://github.com/jacquerie","followers_url":"https://api.github.com/users/jacquerie/followers","following_url":"https://api.github.com/users/jacquerie/following{/other_user}","gists_url":"https://api.github.com/users/jacquerie/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquerie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquerie/subscriptions","organizations_url":"https://api.github.com/users/jacquerie/orgs","repos_url":"https://api.github.com/users/jacquerie/repos","events_url":"https://api.github.com/users/jacquerie/events{/privacy}","received_events_url":"https://api.github.com/users/jacquerie/received_events","type":"User","site_admin":false},"repo":{"id":30291666,"name":"invenio","full_name":"jacquerie/invenio","owner":{"login":"jacquerie","id":381280,"avatar_url":"https://avatars.githubusercontent.com/u/381280?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquerie","html_url":"https://github.com/jacquerie","followers_url":"https://api.github.com/users/jacquerie/followers","following_url":"https://api.github.com/users/jacquerie/following{/other_user}","gists_url":"https://api.github.com/users/jacquerie/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquerie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquerie/subscriptions","organizations_url":"https://api.github.com/users/jacquerie/orgs","repos_url":"https://api.github.com/users/jacquerie/repos","events_url":"https://api.github.com/users/jacquerie/events{/privacy}","received_events_url":"https://api.github.com/users/jacquerie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacquerie/invenio","description":"Invenio digital library software","fork":true,"url":"https://api.github.com/repos/jacquerie/invenio","forks_url":"https://api.github.com/repos/jacquerie/invenio/forks","keys_url":"https://api.github.com/repos/jacquerie/invenio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquerie/invenio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquerie/invenio/teams","hooks_url":"https://api.github.com/repos/jacquerie/invenio/hooks","issue_events_url":"https://api.github.com/repos/jacquerie/invenio/issues/events{/number}","events_url":"https://api.github.com/repos/jacquerie/invenio/events","assignees_url":"https://api.github.com/repos/jacquerie/invenio/assignees{/user}","branches_url":"https://api.github.com/repos/jacquerie/invenio/branches{/branch}","tags_url":"https://api.github.com/repos/jacquerie/invenio/tags","blobs_url":"https://api.github.com/repos/jacquerie/invenio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquerie/invenio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquerie/invenio/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquerie/invenio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquerie/invenio/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquerie/invenio/languages","stargazers_url":"https://api.github.com/repos/jacquerie/invenio/stargazers","contributors_url":"https://api.github.com/repos/jacquerie/invenio/contributors","subscribers_url":"https://api.github.com/repos/jacquerie/invenio/subscribers","subscription_url":"https://api.github.com/repos/jacquerie/invenio/subscription","commits_url":"https://api.github.com/repos/jacquerie/invenio/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquerie/invenio/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquerie/invenio/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquerie/invenio/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquerie/invenio/contents/{+path}","compare_url":"https://api.github.com/repos/jacquerie/invenio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquerie/invenio/merges","archive_url":"https://api.github.com/repos/jacquerie/invenio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquerie/invenio/downloads","issues_url":"https://api.github.com/repos/jacquerie/invenio/issues{/number}","pulls_url":"https://api.github.com/repos/jacquerie/invenio/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquerie/invenio/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquerie/invenio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquerie/invenio/labels{/name}","releases_url":"https://api.github.com/repos/jacquerie/invenio/releases{/id}","created_at":"2015-02-04T09:38:21Z","updated_at":"2015-02-16T13:20:51Z","pushed_at":"2015-03-18T17:01:04Z","git_url":"git://github.com/jacquerie/invenio.git","ssh_url":"git@github.com:jacquerie/invenio.git","clone_url":"https://github.com/jacquerie/invenio.git","svn_url":"https://github.com/jacquerie/invenio","homepage":"http://invenio-software.org/","size":80232,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"pu"}},"base":{"label":"inveniosoftware:master","ref":"master","sha":"6608e6d8273563efb7a8c26204c69cc80211e86e","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":2665618,"name":"invenio","full_name":"inveniosoftware/invenio","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","description":"Invenio digital library software","fork":false,"url":"https://api.github.com/repos/inveniosoftware/invenio","forks_url":"https://api.github.com/repos/inveniosoftware/invenio/forks","keys_url":"https://api.github.com/repos/inveniosoftware/invenio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inveniosoftware/invenio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inveniosoftware/invenio/teams","hooks_url":"https://api.github.com/repos/inveniosoftware/invenio/hooks","issue_events_url":"https://api.github.com/repos/inveniosoftware/invenio/issues/events{/number}","events_url":"https://api.github.com/repos/inveniosoftware/invenio/events","assignees_url":"https://api.github.com/repos/inveniosoftware/invenio/assignees{/user}","branches_url":"https://api.github.com/repos/inveniosoftware/invenio/branches{/branch}","tags_url":"https://api.github.com/repos/inveniosoftware/invenio/tags","blobs_url":"https://api.github.com/repos/inveniosoftware/invenio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inveniosoftware/invenio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inveniosoftware/invenio/git/refs{/sha}","trees_url":"https://api.github.com/repos/inveniosoftware/invenio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inveniosoftware/invenio/statuses/{sha}","languages_url":"https://api.github.com/repos/inveniosoftware/invenio/languages","stargazers_url":"https://api.github.com/repos/inveniosoftware/invenio/stargazers","contributors_url":"https://api.github.com/repos/inveniosoftware/invenio/contributors","subscribers_url":"https://api.github.com/repos/inveniosoftware/invenio/subscribers","subscription_url":"https://api.github.com/repos/inveniosoftware/invenio/subscription","commits_url":"https://api.github.com/repos/inveniosoftware/invenio/commits{/sha}","git_commits_url":"https://api.github.com/repos/inveniosoftware/invenio/git/commits{/sha}","comments_url":"https://api.github.com/repos/inveniosoftware/invenio/comments{/number}","issue_comment_url":"https://api.github.com/repos/inveniosoftware/invenio/issues/comments{/number}","contents_url":"https://api.github.com/repos/inveniosoftware/invenio/contents/{+path}","compare_url":"https://api.github.com/repos/inveniosoftware/invenio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inveniosoftware/invenio/merges","archive_url":"https://api.github.com/repos/inveniosoftware/invenio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inveniosoftware/invenio/downloads","issues_url":"https://api.github.com/repos/inveniosoftware/invenio/issues{/number}","pulls_url":"https://api.github.com/repos/inveniosoftware/invenio/pulls{/number}","milestones_url":"https://api.github.com/repos/inveniosoftware/invenio/milestones{/number}","notifications_url":"https://api.github.com/repos/inveniosoftware/invenio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inveniosoftware/invenio/labels{/name}","releases_url":"https://api.github.com/repos/inveniosoftware/invenio/releases{/id}","created_at":"2011-10-28T14:33:51Z","updated_at":"2015-03-19T08:19:17Z","pushed_at":"2015-03-19T08:27:32Z","git_url":"git://github.com/inveniosoftware/invenio.git","ssh_url":"git@github.com:inveniosoftware/invenio.git","clone_url":"https://github.com/inveniosoftware/invenio.git","svn_url":"https://github.com/inveniosoftware/invenio","homepage":"http://invenio-software.org/","size":98162,"stargazers_count":51,"watchers_count":51,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":116,"mirror_url":null,"open_issues_count":859,"forks":116,"open_issues":859,"watchers":51,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903"},"html":{"href":"https://github.com/inveniosoftware/invenio/pull/2903"},"issue":{"href":"https://api.github.com/repos/inveniosoftware/invenio/issues/2903"},"comments":{"href":"https://api.github.com/repos/inveniosoftware/invenio/issues/2903/comments"},"review_comments":{"href":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903/comments"},"review_comment":{"href":"https://api.github.com/repos/inveniosoftware/invenio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inveniosoftware/invenio/pulls/2903/commits"},"statuses":{"href":"https://api.github.com/repos/inveniosoftware/invenio/statuses/06e97e4b0c608aedd45a1d67c2b19cfb4b1d3712"}}}}