{"action":"created","comment":{"url":"https://api.github.com/repos/level12/keg-elements/pulls/comments/76808913","id":76808913,"diff_hunk":"@@ -67,30 +67,116 @@ def from_dict(self, data):\n             else:\n                 setattr(self, key, value)\n \n-    def to_dict(self, exclude=None):\n-        if exclude is None:\n-            exclude = []\n-        insp = sainsp(self)\n-        return dict((attr.key, attr.value)\n-                    for attr in insp.attrs if attr.key not in exclude)\n+    def to_dict(self, exclude=[], hybrids=[]):\n+        \"\"\"Covert the object properties to a dictionary.\n+\n+        :param exclude: a list of columns to ignore\n+        :param hybrids: a list of the hybrid properties to include in the dictionary.\n+        :returns: a dictionary representation of the object\n+\n+        .. note: By default hybrid properties are not included in the returned dict. To add a hybrid\n+        property to the returned dict pass a list of the property names and they will be included.\n+        \"\"\"\n+        data = dict([(name, getattr(self, name))\n+                     for name in self.column_names()\n+                     if name not in exclude])\n+\n+        for hybrid in hybrids:\n+            data[hybrid] = getattr(self, hybrid)\n+\n+        return data\n+\n+    @might_commit\n+    @might_flush\n+    @classmethod\n+    def add(cls, **kwargs):\n+        obj = cls()\n+        obj.from_dict(kwargs)\n+        db.session.add(obj)\n+        return obj\n+\n+    @might_commit\n+    @might_flush\n+    @classmethod\n+    def delete(cls, oid):\n+        \"\"\"Delete an object from the session\n+\n+        :param oid: the object identifier, normally the primary key\n+        :rtype: bool\n+        :return: The result of the operation\n+        \"\"\"\n+        obj = cls.query.get(oid)\n+\n+        if obj is None:\n+            return False\n+\n+        db.session.delete(obj)\n+        return True\n+\n+    @might_commit\n+    @classmethod\n+    def delete_cascaded(cls):\n+        cls.query.delete(synchronize_session=False)\n+        db.session.expire_all()\n+\n+    @classmethod\n+    def column_names(cls):\n+        return {col.key for col in cls.__mapper__.columns}","path":"keg_elements/db/mixins.py","position":103,"original_position":103,"commit_id":"1641a005d9a85b5f3349612c53376a9e5df055c0","original_commit_id":"1641a005d9a85b5f3349612c53376a9e5df055c0","user":{"login":"rsyring","id":109467,"avatar_url":"https://avatars.githubusercontent.com/u/109467?v=3","gravatar_id":"","url":"https://api.github.com/users/rsyring","html_url":"https://github.com/rsyring","followers_url":"https://api.github.com/users/rsyring/followers","following_url":"https://api.github.com/users/rsyring/following{/other_user}","gists_url":"https://api.github.com/users/rsyring/gists{/gist_id}","starred_url":"https://api.github.com/users/rsyring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsyring/subscriptions","organizations_url":"https://api.github.com/users/rsyring/orgs","repos_url":"https://api.github.com/users/rsyring/repos","events_url":"https://api.github.com/users/rsyring/events{/privacy}","received_events_url":"https://api.github.com/users/rsyring/received_events","type":"User","site_admin":false},"body":"I never really thought about getting rid of columns from the collection like that.  I like it, although wondering how often I would use it.  What if we made the return type optional:\r\n\r\n`def column_names(cls, as_set=False):` ?\r\n\r\n","created_at":"2016-08-30T14:42:24Z","updated_at":"2016-08-30T14:42:24Z","html_url":"https://github.com/level12/keg-elements/pull/49#discussion_r76808913","pull_request_url":"https://api.github.com/repos/level12/keg-elements/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/level12/keg-elements/pulls/comments/76808913"},"html":{"href":"https://github.com/level12/keg-elements/pull/49#discussion_r76808913"},"pull_request":{"href":"https://api.github.com/repos/level12/keg-elements/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/level12/keg-elements/pulls/49","id":83199970,"html_url":"https://github.com/level12/keg-elements/pull/49","diff_url":"https://github.com/level12/keg-elements/pull/49.diff","patch_url":"https://github.com/level12/keg-elements/pull/49.patch","issue_url":"https://api.github.com/repos/level12/keg-elements/issues/49","number":49,"state":"open","locked":false,"title":"Port over methods mixins","user":{"login":"nZac","id":276212,"avatar_url":"https://avatars.githubusercontent.com/u/276212?v=3","gravatar_id":"","url":"https://api.github.com/users/nZac","html_url":"https://github.com/nZac","followers_url":"https://api.github.com/users/nZac/followers","following_url":"https://api.github.com/users/nZac/following{/other_user}","gists_url":"https://api.github.com/users/nZac/gists{/gist_id}","starred_url":"https://api.github.com/users/nZac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nZac/subscriptions","organizations_url":"https://api.github.com/users/nZac/orgs","repos_url":"https://api.github.com/users/nZac/repos","events_url":"https://api.github.com/users/nZac/events{/privacy}","received_events_url":"https://api.github.com/users/nZac/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-30T02:42:00Z","updated_at":"2016-08-30T14:42:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78588c5496bbc63476cc7e779b7be8d39741ed44","assignee":{"login":"rsyring","id":109467,"avatar_url":"https://avatars.githubusercontent.com/u/109467?v=3","gravatar_id":"","url":"https://api.github.com/users/rsyring","html_url":"https://github.com/rsyring","followers_url":"https://api.github.com/users/rsyring/followers","following_url":"https://api.github.com/users/rsyring/following{/other_user}","gists_url":"https://api.github.com/users/rsyring/gists{/gist_id}","starred_url":"https://api.github.com/users/rsyring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsyring/subscriptions","organizations_url":"https://api.github.com/users/rsyring/orgs","repos_url":"https://api.github.com/users/rsyring/repos","events_url":"https://api.github.com/users/rsyring/events{/privacy}","received_events_url":"https://api.github.com/users/rsyring/received_events","type":"User","site_admin":false},"assignees":[{"login":"rsyring","id":109467,"avatar_url":"https://avatars.githubusercontent.com/u/109467?v=3","gravatar_id":"","url":"https://api.github.com/users/rsyring","html_url":"https://github.com/rsyring","followers_url":"https://api.github.com/users/rsyring/followers","following_url":"https://api.github.com/users/rsyring/following{/other_user}","gists_url":"https://api.github.com/users/rsyring/gists{/gist_id}","starred_url":"https://api.github.com/users/rsyring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsyring/subscriptions","organizations_url":"https://api.github.com/users/rsyring/orgs","repos_url":"https://api.github.com/users/rsyring/repos","events_url":"https://api.github.com/users/rsyring/events{/privacy}","received_events_url":"https://api.github.com/users/rsyring/received_events","type":"User","site_admin":false},{"login":"3noch","id":882455,"avatar_url":"https://avatars.githubusercontent.com/u/882455?v=3","gravatar_id":"","url":"https://api.github.com/users/3noch","html_url":"https://github.com/3noch","followers_url":"https://api.github.com/users/3noch/followers","following_url":"https://api.github.com/users/3noch/following{/other_user}","gists_url":"https://api.github.com/users/3noch/gists{/gist_id}","starred_url":"https://api.github.com/users/3noch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3noch/subscriptions","organizations_url":"https://api.github.com/users/3noch/orgs","repos_url":"https://api.github.com/users/3noch/repos","events_url":"https://api.github.com/users/3noch/events{/privacy}","received_events_url":"https://api.github.com/users/3noch/received_events","type":"User","site_admin":false},{"login":"bladams","id":8389598,"avatar_url":"https://avatars.githubusercontent.com/u/8389598?v=3","gravatar_id":"","url":"https://api.github.com/users/bladams","html_url":"https://github.com/bladams","followers_url":"https://api.github.com/users/bladams/followers","following_url":"https://api.github.com/users/bladams/following{/other_user}","gists_url":"https://api.github.com/users/bladams/gists{/gist_id}","starred_url":"https://api.github.com/users/bladams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bladams/subscriptions","organizations_url":"https://api.github.com/users/bladams/orgs","repos_url":"https://api.github.com/users/bladams/repos","events_url":"https://api.github.com/users/bladams/events{/privacy}","received_events_url":"https://api.github.com/users/bladams/received_events","type":"User","site_admin":false},{"login":"guruofgentoo","id":8727453,"avatar_url":"https://avatars.githubusercontent.com/u/8727453?v=3","gravatar_id":"","url":"https://api.github.com/users/guruofgentoo","html_url":"https://github.com/guruofgentoo","followers_url":"https://api.github.com/users/guruofgentoo/followers","following_url":"https://api.github.com/users/guruofgentoo/following{/other_user}","gists_url":"https://api.github.com/users/guruofgentoo/gists{/gist_id}","starred_url":"https://api.github.com/users/guruofgentoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guruofgentoo/subscriptions","organizations_url":"https://api.github.com/users/guruofgentoo/orgs","repos_url":"https://api.github.com/users/guruofgentoo/repos","events_url":"https://api.github.com/users/guruofgentoo/events{/privacy}","received_events_url":"https://api.github.com/users/guruofgentoo/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/level12/keg-elements/pulls/49/commits","review_comments_url":"https://api.github.com/repos/level12/keg-elements/pulls/49/comments","review_comment_url":"https://api.github.com/repos/level12/keg-elements/pulls/comments{/number}","comments_url":"https://api.github.com/repos/level12/keg-elements/issues/49/comments","statuses_url":"https://api.github.com/repos/level12/keg-elements/statuses/1641a005d9a85b5f3349612c53376a9e5df055c0","head":{"label":"level12:port-over-methods-mixins","ref":"port-over-methods-mixins","sha":"1641a005d9a85b5f3349612c53376a9e5df055c0","user":{"login":"level12","id":11673919,"avatar_url":"https://avatars.githubusercontent.com/u/11673919?v=3","gravatar_id":"","url":"https://api.github.com/users/level12","html_url":"https://github.com/level12","followers_url":"https://api.github.com/users/level12/followers","following_url":"https://api.github.com/users/level12/following{/other_user}","gists_url":"https://api.github.com/users/level12/gists{/gist_id}","starred_url":"https://api.github.com/users/level12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/level12/subscriptions","organizations_url":"https://api.github.com/users/level12/orgs","repos_url":"https://api.github.com/users/level12/repos","events_url":"https://api.github.com/users/level12/events{/privacy}","received_events_url":"https://api.github.com/users/level12/received_events","type":"Organization","site_admin":false},"repo":{"id":36879487,"name":"keg-elements","full_name":"level12/keg-elements","owner":{"login":"level12","id":11673919,"avatar_url":"https://avatars.githubusercontent.com/u/11673919?v=3","gravatar_id":"","url":"https://api.github.com/users/level12","html_url":"https://github.com/level12","followers_url":"https://api.github.com/users/level12/followers","following_url":"https://api.github.com/users/level12/following{/other_user}","gists_url":"https://api.github.com/users/level12/gists{/gist_id}","starred_url":"https://api.github.com/users/level12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/level12/subscriptions","organizations_url":"https://api.github.com/users/level12/orgs","repos_url":"https://api.github.com/users/level12/repos","events_url":"https://api.github.com/users/level12/events{/privacy}","received_events_url":"https://api.github.com/users/level12/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/level12/keg-elements","description":"","fork":false,"url":"https://api.github.com/repos/level12/keg-elements","forks_url":"https://api.github.com/repos/level12/keg-elements/forks","keys_url":"https://api.github.com/repos/level12/keg-elements/keys{/key_id}","collaborators_url":"https://api.github.com/repos/level12/keg-elements/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/level12/keg-elements/teams","hooks_url":"https://api.github.com/repos/level12/keg-elements/hooks","issue_events_url":"https://api.github.com/repos/level12/keg-elements/issues/events{/number}","events_url":"https://api.github.com/repos/level12/keg-elements/events","assignees_url":"https://api.github.com/repos/level12/keg-elements/assignees{/user}","branches_url":"https://api.github.com/repos/level12/keg-elements/branches{/branch}","tags_url":"https://api.github.com/repos/level12/keg-elements/tags","blobs_url":"https://api.github.com/repos/level12/keg-elements/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/level12/keg-elements/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/level12/keg-elements/git/refs{/sha}","trees_url":"https://api.github.com/repos/level12/keg-elements/git/trees{/sha}","statuses_url":"https://api.github.com/repos/level12/keg-elements/statuses/{sha}","languages_url":"https://api.github.com/repos/level12/keg-elements/languages","stargazers_url":"https://api.github.com/repos/level12/keg-elements/stargazers","contributors_url":"https://api.github.com/repos/level12/keg-elements/contributors","subscribers_url":"https://api.github.com/repos/level12/keg-elements/subscribers","subscription_url":"https://api.github.com/repos/level12/keg-elements/subscription","commits_url":"https://api.github.com/repos/level12/keg-elements/commits{/sha}","git_commits_url":"https://api.github.com/repos/level12/keg-elements/git/commits{/sha}","comments_url":"https://api.github.com/repos/level12/keg-elements/comments{/number}","issue_comment_url":"https://api.github.com/repos/level12/keg-elements/issues/comments{/number}","contents_url":"https://api.github.com/repos/level12/keg-elements/contents/{+path}","compare_url":"https://api.github.com/repos/level12/keg-elements/compare/{base}...{head}","merges_url":"https://api.github.com/repos/level12/keg-elements/merges","archive_url":"https://api.github.com/repos/level12/keg-elements/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/level12/keg-elements/downloads","issues_url":"https://api.github.com/repos/level12/keg-elements/issues{/number}","pulls_url":"https://api.github.com/repos/level12/keg-elements/pulls{/number}","milestones_url":"https://api.github.com/repos/level12/keg-elements/milestones{/number}","notifications_url":"https://api.github.com/repos/level12/keg-elements/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/level12/keg-elements/labels{/name}","releases_url":"https://api.github.com/repos/level12/keg-elements/releases{/id}","deployments_url":"https://api.github.com/repos/level12/keg-elements/deployments","created_at":"2015-06-04T15:38:31Z","updated_at":"2016-02-05T22:00:19Z","pushed_at":"2016-08-30T02:45:53Z","git_url":"git://github.com/level12/keg-elements.git","ssh_url":"git@github.com:level12/keg-elements.git","clone_url":"https://github.com/level12/keg-elements.git","svn_url":"https://github.com/level12/keg-elements","homepage":null,"size":39012,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":13,"forks":3,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"level12:master","ref":"master","sha":"cf3d12ea741af3bcb832d84f1f139995280f3c1a","user":{"login":"level12","id":11673919,"avatar_url":"https://avatars.githubusercontent.com/u/11673919?v=3","gravatar_id":"","url":"https://api.github.com/users/level12","html_url":"https://github.com/level12","followers_url":"https://api.github.com/users/level12/followers","following_url":"https://api.github.com/users/level12/following{/other_user}","gists_url":"https://api.github.com/users/level12/gists{/gist_id}","starred_url":"https://api.github.com/users/level12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/level12/subscriptions","organizations_url":"https://api.github.com/users/level12/orgs","repos_url":"https://api.github.com/users/level12/repos","events_url":"https://api.github.com/users/level12/events{/privacy}","received_events_url":"https://api.github.com/users/level12/received_events","type":"Organization","site_admin":false},"repo":{"id":36879487,"name":"keg-elements","full_name":"level12/keg-elements","owner":{"login":"level12","id":11673919,"avatar_url":"https://avatars.githubusercontent.com/u/11673919?v=3","gravatar_id":"","url":"https://api.github.com/users/level12","html_url":"https://github.com/level12","followers_url":"https://api.github.com/users/level12/followers","following_url":"https://api.github.com/users/level12/following{/other_user}","gists_url":"https://api.github.com/users/level12/gists{/gist_id}","starred_url":"https://api.github.com/users/level12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/level12/subscriptions","organizations_url":"https://api.github.com/users/level12/orgs","repos_url":"https://api.github.com/users/level12/repos","events_url":"https://api.github.com/users/level12/events{/privacy}","received_events_url":"https://api.github.com/users/level12/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/level12/keg-elements","description":"","fork":false,"url":"https://api.github.com/repos/level12/keg-elements","forks_url":"https://api.github.com/repos/level12/keg-elements/forks","keys_url":"https://api.github.com/repos/level12/keg-elements/keys{/key_id}","collaborators_url":"https://api.github.com/repos/level12/keg-elements/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/level12/keg-elements/teams","hooks_url":"https://api.github.com/repos/level12/keg-elements/hooks","issue_events_url":"https://api.github.com/repos/level12/keg-elements/issues/events{/number}","events_url":"https://api.github.com/repos/level12/keg-elements/events","assignees_url":"https://api.github.com/repos/level12/keg-elements/assignees{/user}","branches_url":"https://api.github.com/repos/level12/keg-elements/branches{/branch}","tags_url":"https://api.github.com/repos/level12/keg-elements/tags","blobs_url":"https://api.github.com/repos/level12/keg-elements/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/level12/keg-elements/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/level12/keg-elements/git/refs{/sha}","trees_url":"https://api.github.com/repos/level12/keg-elements/git/trees{/sha}","statuses_url":"https://api.github.com/repos/level12/keg-elements/statuses/{sha}","languages_url":"https://api.github.com/repos/level12/keg-elements/languages","stargazers_url":"https://api.github.com/repos/level12/keg-elements/stargazers","contributors_url":"https://api.github.com/repos/level12/keg-elements/contributors","subscribers_url":"https://api.github.com/repos/level12/keg-elements/subscribers","subscription_url":"https://api.github.com/repos/level12/keg-elements/subscription","commits_url":"https://api.github.com/repos/level12/keg-elements/commits{/sha}","git_commits_url":"https://api.github.com/repos/level12/keg-elements/git/commits{/sha}","comments_url":"https://api.github.com/repos/level12/keg-elements/comments{/number}","issue_comment_url":"https://api.github.com/repos/level12/keg-elements/issues/comments{/number}","contents_url":"https://api.github.com/repos/level12/keg-elements/contents/{+path}","compare_url":"https://api.github.com/repos/level12/keg-elements/compare/{base}...{head}","merges_url":"https://api.github.com/repos/level12/keg-elements/merges","archive_url":"https://api.github.com/repos/level12/keg-elements/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/level12/keg-elements/downloads","issues_url":"https://api.github.com/repos/level12/keg-elements/issues{/number}","pulls_url":"https://api.github.com/repos/level12/keg-elements/pulls{/number}","milestones_url":"https://api.github.com/repos/level12/keg-elements/milestones{/number}","notifications_url":"https://api.github.com/repos/level12/keg-elements/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/level12/keg-elements/labels{/name}","releases_url":"https://api.github.com/repos/level12/keg-elements/releases{/id}","deployments_url":"https://api.github.com/repos/level12/keg-elements/deployments","created_at":"2015-06-04T15:38:31Z","updated_at":"2016-02-05T22:00:19Z","pushed_at":"2016-08-30T02:45:53Z","git_url":"git://github.com/level12/keg-elements.git","ssh_url":"git@github.com:level12/keg-elements.git","clone_url":"https://github.com/level12/keg-elements.git","svn_url":"https://github.com/level12/keg-elements","homepage":null,"size":39012,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":13,"forks":3,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/level12/keg-elements/pulls/49"},"html":{"href":"https://github.com/level12/keg-elements/pull/49"},"issue":{"href":"https://api.github.com/repos/level12/keg-elements/issues/49"},"comments":{"href":"https://api.github.com/repos/level12/keg-elements/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/level12/keg-elements/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/level12/keg-elements/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/level12/keg-elements/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/level12/keg-elements/statuses/1641a005d9a85b5f3349612c53376a9e5df055c0"}}}}
{"actor":{"display_login":"rsyring"}}