{"action":"created","comment":{"url":"https://api.github.com/repos/magfest/ubersystem/pulls/comments/39119505","id":39119505,"diff_hunk":"@@ -195,6 +195,11 @@ def PAGE(self):\n         return cherrypy.request.path_info.split('/')[-1]\n \n     @property","path":"uber/config.py","position":3,"original_position":3,"commit_id":"28d748e6a223f2ae2b7db09eff274ce1058f274a","original_commit_id":"28d748e6a223f2ae2b7db09eff274ce1058f274a","user":{"login":"EliAndrewC","id":651592,"avatar_url":"https://avatars.githubusercontent.com/u/651592?v=3","gravatar_id":"","url":"https://api.github.com/users/EliAndrewC","html_url":"https://github.com/EliAndrewC","followers_url":"https://api.github.com/users/EliAndrewC/followers","following_url":"https://api.github.com/users/EliAndrewC/following{/other_user}","gists_url":"https://api.github.com/users/EliAndrewC/gists{/gist_id}","starred_url":"https://api.github.com/users/EliAndrewC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EliAndrewC/subscriptions","organizations_url":"https://api.github.com/users/EliAndrewC/orgs","repos_url":"https://api.github.com/users/EliAndrewC/repos","events_url":"https://api.github.com/users/EliAndrewC/events{/privacy}","received_events_url":"https://api.github.com/users/EliAndrewC/received_events","type":"User","site_admin":false},"body":"I'm pretty sure this will raise an exception if you actually try to use it.  (Or if would if you called the ``session.admin_attendee()`` function instead of just returning the method without calling it, which I'm guessing was a mistake.)\r\n\r\nOne thing that's not intuitive about SQLAlchemy models is that they're either \"attached\" or \"detached\".  For example:\r\n\r\n```python\r\n    # I added this to the Config class for testing/demonstration purposes:\r\n    @property\r\n    def SOME_ATTENDEE(self):\r\n        with sa.Session() as session:\r\n            return session.query(sa.Attendee).first()\r\n\r\n...\r\n>>> c.SOME_ATTENDEE.first_name\r\nTraceback (most recent call last):\r\n...\r\nsqlalchemy.orm.exc.DetachedInstanceError: Instance <Attendee at 0x7f467b6027b8> is not bound to a Session; attribute refresh operation cannot proceed\r\n```\r\n\r\nBasically, if you retrieve a model instance from the database and then the session closes, you can no longer access data on that model, on the logic that you no longer have any idea whether the data is still valid.  This is why ``admin_attendee()`` is a method on the ``session`` class instead of on the ``c`` object.\r\n\r\nWith that being said, there's a valid use case here, which is that maybe we want to just return whatever is in the database at the moment and we don't care if it gets modified 1 millisecond later (because how often does the current admin edit e.g. their own name, anyway?).\r\n\r\nIn this case, the idiomatic SQLAlchemy approach would be to return the data rather than the model itself, e.g.\r\n\r\n```python\r\n    @property\r\n    def CURRENT_ADMIN_NAME(self):\r\n        with sa.Session() as session:\r\n            return session.admin_attendee().full_name\r\n```\r\n\r\nor if you wanted to return more of the data, you could use the ``to_dict()`` method, e.g.\r\n\r\n```python\r\n    @property\r\n    def CURRENT_ADMIN_NAME(self):\r\n        with sa.Session() as session:\r\n            return session.admin_attendee().to_dict()\r\n```","created_at":"2015-09-10T02:34:03Z","updated_at":"2015-09-10T02:34:03Z","html_url":"https://github.com/magfest/ubersystem/pull/1480#discussion_r39119505","pull_request_url":"https://api.github.com/repos/magfest/ubersystem/pulls/1480","_links":{"self":{"href":"https://api.github.com/repos/magfest/ubersystem/pulls/comments/39119505"},"html":{"href":"https://github.com/magfest/ubersystem/pull/1480#discussion_r39119505"},"pull_request":{"href":"https://api.github.com/repos/magfest/ubersystem/pulls/1480"}}},"pull_request":{"url":"https://api.github.com/repos/magfest/ubersystem/pulls/1480","id":44581245,"html_url":"https://github.com/magfest/ubersystem/pull/1480","diff_url":"https://github.com/magfest/ubersystem/pull/1480.diff","patch_url":"https://github.com/magfest/ubersystem/pull/1480.patch","issue_url":"https://api.github.com/repos/magfest/ubersystem/issues/1480","number":1480,"state":"open","locked":false,"title":"Add tooltips and logged-in user to nav-bar","user":{"login":"kitsuta","id":7198215,"avatar_url":"https://avatars.githubusercontent.com/u/7198215?v=3","gravatar_id":"","url":"https://api.github.com/users/kitsuta","html_url":"https://github.com/kitsuta","followers_url":"https://api.github.com/users/kitsuta/followers","following_url":"https://api.github.com/users/kitsuta/following{/other_user}","gists_url":"https://api.github.com/users/kitsuta/gists{/gist_id}","starred_url":"https://api.github.com/users/kitsuta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kitsuta/subscriptions","organizations_url":"https://api.github.com/users/kitsuta/orgs","repos_url":"https://api.github.com/users/kitsuta/repos","events_url":"https://api.github.com/users/kitsuta/events{/privacy}","received_events_url":"https://api.github.com/users/kitsuta/received_events","type":"User","site_admin":false},"body":"Fixes https://github.com/magfest/ubersystem/issues/1212.","created_at":"2015-09-09T18:03:04Z","updated_at":"2015-09-10T02:34:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf2bd9656c2495084ef55f224686e1a9a67c9bef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/magfest/ubersystem/pulls/1480/commits","review_comments_url":"https://api.github.com/repos/magfest/ubersystem/pulls/1480/comments","review_comment_url":"https://api.github.com/repos/magfest/ubersystem/pulls/comments{/number}","comments_url":"https://api.github.com/repos/magfest/ubersystem/issues/1480/comments","statuses_url":"https://api.github.com/repos/magfest/ubersystem/statuses/28d748e6a223f2ae2b7db09eff274ce1058f274a","head":{"label":"magfest:improve-navbar","ref":"improve-navbar","sha":"28d748e6a223f2ae2b7db09eff274ce1058f274a","user":{"login":"magfest","id":7840140,"avatar_url":"https://avatars.githubusercontent.com/u/7840140?v=3","gravatar_id":"","url":"https://api.github.com/users/magfest","html_url":"https://github.com/magfest","followers_url":"https://api.github.com/users/magfest/followers","following_url":"https://api.github.com/users/magfest/following{/other_user}","gists_url":"https://api.github.com/users/magfest/gists{/gist_id}","starred_url":"https://api.github.com/users/magfest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magfest/subscriptions","organizations_url":"https://api.github.com/users/magfest/orgs","repos_url":"https://api.github.com/users/magfest/repos","events_url":"https://api.github.com/users/magfest/events{/privacy}","received_events_url":"https://api.github.com/users/magfest/received_events","type":"Organization","site_admin":false},"repo":{"id":16427229,"name":"ubersystem","full_name":"magfest/ubersystem","owner":{"login":"magfest","id":7840140,"avatar_url":"https://avatars.githubusercontent.com/u/7840140?v=3","gravatar_id":"","url":"https://api.github.com/users/magfest","html_url":"https://github.com/magfest","followers_url":"https://api.github.com/users/magfest/followers","following_url":"https://api.github.com/users/magfest/following{/other_user}","gists_url":"https://api.github.com/users/magfest/gists{/gist_id}","starred_url":"https://api.github.com/users/magfest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magfest/subscriptions","organizations_url":"https://api.github.com/users/magfest/orgs","repos_url":"https://api.github.com/users/magfest/repos","events_url":"https://api.github.com/users/magfest/events{/privacy}","received_events_url":"https://api.github.com/users/magfest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/magfest/ubersystem","description":"MAGFest's Ubersystem - handles ticketing, staffing, analytics, volunteers, and tons more","fork":false,"url":"https://api.github.com/repos/magfest/ubersystem","forks_url":"https://api.github.com/repos/magfest/ubersystem/forks","keys_url":"https://api.github.com/repos/magfest/ubersystem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magfest/ubersystem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magfest/ubersystem/teams","hooks_url":"https://api.github.com/repos/magfest/ubersystem/hooks","issue_events_url":"https://api.github.com/repos/magfest/ubersystem/issues/events{/number}","events_url":"https://api.github.com/repos/magfest/ubersystem/events","assignees_url":"https://api.github.com/repos/magfest/ubersystem/assignees{/user}","branches_url":"https://api.github.com/repos/magfest/ubersystem/branches{/branch}","tags_url":"https://api.github.com/repos/magfest/ubersystem/tags","blobs_url":"https://api.github.com/repos/magfest/ubersystem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magfest/ubersystem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magfest/ubersystem/git/refs{/sha}","trees_url":"https://api.github.com/repos/magfest/ubersystem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magfest/ubersystem/statuses/{sha}","languages_url":"https://api.github.com/repos/magfest/ubersystem/languages","stargazers_url":"https://api.github.com/repos/magfest/ubersystem/stargazers","contributors_url":"https://api.github.com/repos/magfest/ubersystem/contributors","subscribers_url":"https://api.github.com/repos/magfest/ubersystem/subscribers","subscription_url":"https://api.github.com/repos/magfest/ubersystem/subscription","commits_url":"https://api.github.com/repos/magfest/ubersystem/commits{/sha}","git_commits_url":"https://api.github.com/repos/magfest/ubersystem/git/commits{/sha}","comments_url":"https://api.github.com/repos/magfest/ubersystem/comments{/number}","issue_comment_url":"https://api.github.com/repos/magfest/ubersystem/issues/comments{/number}","contents_url":"https://api.github.com/repos/magfest/ubersystem/contents/{+path}","compare_url":"https://api.github.com/repos/magfest/ubersystem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magfest/ubersystem/merges","archive_url":"https://api.github.com/repos/magfest/ubersystem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magfest/ubersystem/downloads","issues_url":"https://api.github.com/repos/magfest/ubersystem/issues{/number}","pulls_url":"https://api.github.com/repos/magfest/ubersystem/pulls{/number}","milestones_url":"https://api.github.com/repos/magfest/ubersystem/milestones{/number}","notifications_url":"https://api.github.com/repos/magfest/ubersystem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magfest/ubersystem/labels{/name}","releases_url":"https://api.github.com/repos/magfest/ubersystem/releases{/id}","created_at":"2014-02-01T02:56:25Z","updated_at":"2015-09-03T22:46:33Z","pushed_at":"2015-09-09T22:49:40Z","git_url":"git://github.com/magfest/ubersystem.git","ssh_url":"git@github.com:magfest/ubersystem.git","clone_url":"https://github.com/magfest/ubersystem.git","svn_url":"https://github.com/magfest/ubersystem","homepage":"http://magfest.org","size":65506,"stargazers_count":18,"watchers_count":18,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":215,"forks":24,"open_issues":215,"watchers":18,"default_branch":"master"}},"base":{"label":"magfest:master","ref":"master","sha":"9cf2636279790d6b92d9d5c505af37c1ab2be452","user":{"login":"magfest","id":7840140,"avatar_url":"https://avatars.githubusercontent.com/u/7840140?v=3","gravatar_id":"","url":"https://api.github.com/users/magfest","html_url":"https://github.com/magfest","followers_url":"https://api.github.com/users/magfest/followers","following_url":"https://api.github.com/users/magfest/following{/other_user}","gists_url":"https://api.github.com/users/magfest/gists{/gist_id}","starred_url":"https://api.github.com/users/magfest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magfest/subscriptions","organizations_url":"https://api.github.com/users/magfest/orgs","repos_url":"https://api.github.com/users/magfest/repos","events_url":"https://api.github.com/users/magfest/events{/privacy}","received_events_url":"https://api.github.com/users/magfest/received_events","type":"Organization","site_admin":false},"repo":{"id":16427229,"name":"ubersystem","full_name":"magfest/ubersystem","owner":{"login":"magfest","id":7840140,"avatar_url":"https://avatars.githubusercontent.com/u/7840140?v=3","gravatar_id":"","url":"https://api.github.com/users/magfest","html_url":"https://github.com/magfest","followers_url":"https://api.github.com/users/magfest/followers","following_url":"https://api.github.com/users/magfest/following{/other_user}","gists_url":"https://api.github.com/users/magfest/gists{/gist_id}","starred_url":"https://api.github.com/users/magfest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magfest/subscriptions","organizations_url":"https://api.github.com/users/magfest/orgs","repos_url":"https://api.github.com/users/magfest/repos","events_url":"https://api.github.com/users/magfest/events{/privacy}","received_events_url":"https://api.github.com/users/magfest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/magfest/ubersystem","description":"MAGFest's Ubersystem - handles ticketing, staffing, analytics, volunteers, and tons more","fork":false,"url":"https://api.github.com/repos/magfest/ubersystem","forks_url":"https://api.github.com/repos/magfest/ubersystem/forks","keys_url":"https://api.github.com/repos/magfest/ubersystem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magfest/ubersystem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magfest/ubersystem/teams","hooks_url":"https://api.github.com/repos/magfest/ubersystem/hooks","issue_events_url":"https://api.github.com/repos/magfest/ubersystem/issues/events{/number}","events_url":"https://api.github.com/repos/magfest/ubersystem/events","assignees_url":"https://api.github.com/repos/magfest/ubersystem/assignees{/user}","branches_url":"https://api.github.com/repos/magfest/ubersystem/branches{/branch}","tags_url":"https://api.github.com/repos/magfest/ubersystem/tags","blobs_url":"https://api.github.com/repos/magfest/ubersystem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magfest/ubersystem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magfest/ubersystem/git/refs{/sha}","trees_url":"https://api.github.com/repos/magfest/ubersystem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magfest/ubersystem/statuses/{sha}","languages_url":"https://api.github.com/repos/magfest/ubersystem/languages","stargazers_url":"https://api.github.com/repos/magfest/ubersystem/stargazers","contributors_url":"https://api.github.com/repos/magfest/ubersystem/contributors","subscribers_url":"https://api.github.com/repos/magfest/ubersystem/subscribers","subscription_url":"https://api.github.com/repos/magfest/ubersystem/subscription","commits_url":"https://api.github.com/repos/magfest/ubersystem/commits{/sha}","git_commits_url":"https://api.github.com/repos/magfest/ubersystem/git/commits{/sha}","comments_url":"https://api.github.com/repos/magfest/ubersystem/comments{/number}","issue_comment_url":"https://api.github.com/repos/magfest/ubersystem/issues/comments{/number}","contents_url":"https://api.github.com/repos/magfest/ubersystem/contents/{+path}","compare_url":"https://api.github.com/repos/magfest/ubersystem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magfest/ubersystem/merges","archive_url":"https://api.github.com/repos/magfest/ubersystem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magfest/ubersystem/downloads","issues_url":"https://api.github.com/repos/magfest/ubersystem/issues{/number}","pulls_url":"https://api.github.com/repos/magfest/ubersystem/pulls{/number}","milestones_url":"https://api.github.com/repos/magfest/ubersystem/milestones{/number}","notifications_url":"https://api.github.com/repos/magfest/ubersystem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magfest/ubersystem/labels{/name}","releases_url":"https://api.github.com/repos/magfest/ubersystem/releases{/id}","created_at":"2014-02-01T02:56:25Z","updated_at":"2015-09-03T22:46:33Z","pushed_at":"2015-09-09T22:49:40Z","git_url":"git://github.com/magfest/ubersystem.git","ssh_url":"git@github.com:magfest/ubersystem.git","clone_url":"https://github.com/magfest/ubersystem.git","svn_url":"https://github.com/magfest/ubersystem","homepage":"http://magfest.org","size":65506,"stargazers_count":18,"watchers_count":18,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":215,"forks":24,"open_issues":215,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/magfest/ubersystem/pulls/1480"},"html":{"href":"https://github.com/magfest/ubersystem/pull/1480"},"issue":{"href":"https://api.github.com/repos/magfest/ubersystem/issues/1480"},"comments":{"href":"https://api.github.com/repos/magfest/ubersystem/issues/1480/comments"},"review_comments":{"href":"https://api.github.com/repos/magfest/ubersystem/pulls/1480/comments"},"review_comment":{"href":"https://api.github.com/repos/magfest/ubersystem/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/magfest/ubersystem/pulls/1480/commits"},"statuses":{"href":"https://api.github.com/repos/magfest/ubersystem/statuses/28d748e6a223f2ae2b7db09eff274ce1058f274a"}}}}