GitHub PullRequestReviewCommentEvent at 2014-10-10 01:30:47
Repository: ESP-Website
Actor: luac
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/comments/18685059","id":18685059,"diff_hunk":"@@ -34,27 +34,69 @@\n \"\"\"\n \n import inspect\n+import types\n \n-def get_line_number(obj):\n-    return inspect.getsourcelines(obj)[1]\n+from esp.cache.argcache import ArgCache\n+from esp.cache.marinade import describe_func\n \n-def get_filename(obj):\n-    return inspect.getsourcefile(obj)\n+class ArgCacheDecorator(ArgCache):\n+    \"\"\" An ArgCache that gets its parameters from a function. \"\"\"\n \n-def get_uid(obj):\n-    return '%s:%s' % (get_filename(obj), get_line_number(obj))\n+    def __init__(self, func, *args, **kwargs):\n+        \"\"\" Wrap func in a ArgCache. \"\"\"\n \n-def describe_class(cls):\n-    return '%s.%s' % (cls.__module__.rstrip('.'), cls.__name__)\n+        ## Keep the original function's name and docstring\n+        ## If the original function has any more-complicated attrs,\n+        ## don't bother to maintain them; we have our own attrs,\n+        ## and merging custom stuff could be dangerous.\n+        if hasattr(func, '__name__'):\n+            self.__name__ = func.__name__\n+        if hasattr(func, '__doc__'):\n+            self.__doc__ = func.__doc__\n \n-def describe_func(func):\n-    if hasattr(func, 'im_class'):\n-        # I don't think we actually hit this case... this is only for bound/unbound member functions\n-        return '%s.%s:%s' % (describe_class(func.im_class), func.__name__, get_line_number(func))\n-    else:\n-        #       describe_func -> ArgCache -> ParametrizedSingleton -> containing class/module\n-        class_name = inspect.currentframe().f_back.f_back.f_back.f_code.co_name\n-        if class_name == '<module>':\n-            return '%s.%s' % (func.__module__.rstrip('.'), func.__name__)\n+        self.func = func\n+        extra_name = kwargs.pop('extra_name', '')\n+        name = describe_func(func) + extra_name\n+        params, varargs, keywords, _ = inspect.getargspec(func)\n+        if varargs is not None:\n+            raise ESPError(\"ArgCache does not support varargs.\")\n+        if keywords is not None:\n+            raise ESPError(\"ArgCache does not support keywords.\")\n+\n+        super(ArgCacheDecorator, self).__init__(name=name, params=params, *args, **kwargs)\n+\n+    def arg_list_from(self, *args, **kwargs):","path":"esp/esp/cache/function.py","position":52,"original_position":52,"commit_id":"745291d07b459070b34cfae4075130c0bc025689","original_commit_id":"efaab2051ca6194fd6d0d599a350d3237ab12d06","user":{"login":"luac","id":1305639,"avatar_url":"https://avatars.githubusercontent.com/u/1305639?v=2","gravatar_id":"","url":"https://api.github.com/users/luac","html_url":"https://github.com/luac","followers_url":"https://api.github.com/users/luac/followers","following_url":"https://api.github.com/users/luac/following{/other_user}","gists_url":"https://api.github.com/users/luac/gists{/gist_id}","starred_url":"https://api.github.com/users/luac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luac/subscriptions","organizations_url":"https://api.github.com/users/luac/orgs","repos_url":"https://api.github.com/users/luac/repos","events_url":"https://api.github.com/users/luac/events{/privacy}","received_events_url":"https://api.github.com/users/luac/received_events","type":"User","site_admin":false},"body":"Took another look at this, and noticed that the only place we use `arg_list_from` is in `__call__`, which needs its arguments to be passed as `*args`/`**kwargs` anyway. And if `__call__` were broken in this way, we would know.","created_at":"2014-10-10T01:30:47Z","updated_at":"2014-10-10T01:30:47Z","html_url":"https://github.com/learning-unlimited/ESP-Website/pull/1294#discussion_r18685059","pull_request_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294","_links":{"self":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/comments/18685059"},"html":{"href":"https://github.com/learning-unlimited/ESP-Website/pull/1294#discussion_r18685059"},"pull_request":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294"}}},"pull_request":{"url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294","id":20524235,"html_url":"https://github.com/learning-unlimited/ESP-Website/pull/1294","diff_url":"https://github.com/learning-unlimited/ESP-Website/pull/1294.diff","patch_url":"https://github.com/learning-unlimited/ESP-Website/pull/1294.patch","issue_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/1294","number":1294,"state":"open","locked":false,"title":"Argcache cleanup","user":{"login":"luac","id":1305639,"avatar_url":"https://avatars.githubusercontent.com/u/1305639?v=2","gravatar_id":"","url":"https://api.github.com/users/luac","html_url":"https://github.com/luac","followers_url":"https://api.github.com/users/luac/followers","following_url":"https://api.github.com/users/luac/following{/other_user}","gists_url":"https://api.github.com/users/luac/gists{/gist_id}","starred_url":"https://api.github.com/users/luac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luac/subscriptions","organizations_url":"https://api.github.com/users/luac/orgs","repos_url":"https://api.github.com/users/luac/repos","events_url":"https://api.github.com/users/luac/events{/privacy}","received_events_url":"https://api.github.com/users/luac/received_events","type":"User","site_admin":false},"body":"Clean up various things in the cache framework.\r\n\r\n* Reorganize code; most notably, move `cache_function` from argcache.py to function.py.\r\n* Clean up arg-processing code to use Python 2.7's `inspect.getcallargs` instead of a custom `normalize_args` function.\r\n * To-do: support *args and **kwargs?\r\n* Remove the concept of ArgCache \"uid\"; stop checking for duplicate ArgCaches (which used to be a concern with older versions of Django importing everything twice, but not anymore)\r\n  * To-do: determine whether the cache registry can be gotten rid of or simplified.\r\n* Miscellaneous other code removal/deduplication.","created_at":"2014-08-29T21:24:19Z","updated_at":"2014-10-10T01:30:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02d9ba4bbcbe4ff80382bc366af91edb90b80f1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294/commits","review_comments_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294/comments","review_comment_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/comments/{number}","comments_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/1294/comments","statuses_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/statuses/745291d07b459070b34cfae4075130c0bc025689","head":{"label":"learning-unlimited:argcache-cleanup","ref":"argcache-cleanup","sha":"745291d07b459070b34cfae4075130c0bc025689","user":{"login":"learning-unlimited","id":1150905,"avatar_url":"https://avatars.githubusercontent.com/u/1150905?v=2","gravatar_id":"","url":"https://api.github.com/users/learning-unlimited","html_url":"https://github.com/learning-unlimited","followers_url":"https://api.github.com/users/learning-unlimited/followers","following_url":"https://api.github.com/users/learning-unlimited/following{/other_user}","gists_url":"https://api.github.com/users/learning-unlimited/gists{/gist_id}","starred_url":"https://api.github.com/users/learning-unlimited/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learning-unlimited/subscriptions","organizations_url":"https://api.github.com/users/learning-unlimited/orgs","repos_url":"https://api.github.com/users/learning-unlimited/repos","events_url":"https://api.github.com/users/learning-unlimited/events{/privacy}","received_events_url":"https://api.github.com/users/learning-unlimited/received_events","type":"Organization","site_admin":false},"repo":{"id":2643878,"name":"ESP-Website","full_name":"learning-unlimited/ESP-Website","owner":{"login":"learning-unlimited","id":1150905,"avatar_url":"https://avatars.githubusercontent.com/u/1150905?v=2","gravatar_id":"","url":"https://api.github.com/users/learning-unlimited","html_url":"https://github.com/learning-unlimited","followers_url":"https://api.github.com/users/learning-unlimited/followers","following_url":"https://api.github.com/users/learning-unlimited/following{/other_user}","gists_url":"https://api.github.com/users/learning-unlimited/gists{/gist_id}","starred_url":"https://api.github.com/users/learning-unlimited/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learning-unlimited/subscriptions","organizations_url":"https://api.github.com/users/learning-unlimited/orgs","repos_url":"https://api.github.com/users/learning-unlimited/repos","events_url":"https://api.github.com/users/learning-unlimited/events{/privacy}","received_events_url":"https://api.github.com/users/learning-unlimited/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/learning-unlimited/ESP-Website","description":"A website to help manage the logistics of large short-term educational programs","fork":false,"url":"https://api.github.com/repos/learning-unlimited/ESP-Website","forks_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/forks","keys_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/teams","hooks_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/hooks","issue_events_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/events{/number}","events_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/events","assignees_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/assignees{/user}","branches_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/branches{/branch}","tags_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/tags","blobs_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/refs{/sha}","trees_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/statuses/{sha}","languages_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/languages","stargazers_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/stargazers","contributors_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/contributors","subscribers_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/subscribers","subscription_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/subscription","commits_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/commits{/sha}","git_commits_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/commits{/sha}","comments_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/comments{/number}","issue_comment_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/comments/{number}","contents_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/contents/{+path}","compare_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/merges","archive_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/downloads","issues_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues{/number}","pulls_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls{/number}","milestones_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/milestones{/number}","notifications_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/labels{/name}","releases_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/releases{/id}","created_at":"2011-10-25T14:30:31Z","updated_at":"2014-09-24T18:39:10Z","pushed_at":"2014-10-10T01:26:30Z","git_url":"git://github.com/learning-unlimited/ESP-Website.git","ssh_url":"git@github.com:learning-unlimited/ESP-Website.git","clone_url":"https://github.com/learning-unlimited/ESP-Website.git","svn_url":"https://github.com/learning-unlimited/ESP-Website","homepage":"","size":58318,"stargazers_count":46,"watchers_count":46,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":502,"forks":34,"open_issues":502,"watchers":46,"default_branch":"main"}},"base":{"label":"learning-unlimited:main","ref":"main","sha":"b2690e2f12251341f6439ed0eef77d9d07f5ee5e","user":{"login":"learning-unlimited","id":1150905,"avatar_url":"https://avatars.githubusercontent.com/u/1150905?v=2","gravatar_id":"","url":"https://api.github.com/users/learning-unlimited","html_url":"https://github.com/learning-unlimited","followers_url":"https://api.github.com/users/learning-unlimited/followers","following_url":"https://api.github.com/users/learning-unlimited/following{/other_user}","gists_url":"https://api.github.com/users/learning-unlimited/gists{/gist_id}","starred_url":"https://api.github.com/users/learning-unlimited/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learning-unlimited/subscriptions","organizations_url":"https://api.github.com/users/learning-unlimited/orgs","repos_url":"https://api.github.com/users/learning-unlimited/repos","events_url":"https://api.github.com/users/learning-unlimited/events{/privacy}","received_events_url":"https://api.github.com/users/learning-unlimited/received_events","type":"Organization","site_admin":false},"repo":{"id":2643878,"name":"ESP-Website","full_name":"learning-unlimited/ESP-Website","owner":{"login":"learning-unlimited","id":1150905,"avatar_url":"https://avatars.githubusercontent.com/u/1150905?v=2","gravatar_id":"","url":"https://api.github.com/users/learning-unlimited","html_url":"https://github.com/learning-unlimited","followers_url":"https://api.github.com/users/learning-unlimited/followers","following_url":"https://api.github.com/users/learning-unlimited/following{/other_user}","gists_url":"https://api.github.com/users/learning-unlimited/gists{/gist_id}","starred_url":"https://api.github.com/users/learning-unlimited/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/learning-unlimited/subscriptions","organizations_url":"https://api.github.com/users/learning-unlimited/orgs","repos_url":"https://api.github.com/users/learning-unlimited/repos","events_url":"https://api.github.com/users/learning-unlimited/events{/privacy}","received_events_url":"https://api.github.com/users/learning-unlimited/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/learning-unlimited/ESP-Website","description":"A website to help manage the logistics of large short-term educational programs","fork":false,"url":"https://api.github.com/repos/learning-unlimited/ESP-Website","forks_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/forks","keys_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/teams","hooks_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/hooks","issue_events_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/events{/number}","events_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/events","assignees_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/assignees{/user}","branches_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/branches{/branch}","tags_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/tags","blobs_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/refs{/sha}","trees_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/statuses/{sha}","languages_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/languages","stargazers_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/stargazers","contributors_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/contributors","subscribers_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/subscribers","subscription_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/subscription","commits_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/commits{/sha}","git_commits_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/git/commits{/sha}","comments_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/comments{/number}","issue_comment_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/comments/{number}","contents_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/contents/{+path}","compare_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/merges","archive_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/downloads","issues_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues{/number}","pulls_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls{/number}","milestones_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/milestones{/number}","notifications_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/labels{/name}","releases_url":"https://api.github.com/repos/learning-unlimited/ESP-Website/releases{/id}","created_at":"2011-10-25T14:30:31Z","updated_at":"2014-09-24T18:39:10Z","pushed_at":"2014-10-10T01:26:30Z","git_url":"git://github.com/learning-unlimited/ESP-Website.git","ssh_url":"git@github.com:learning-unlimited/ESP-Website.git","clone_url":"https://github.com/learning-unlimited/ESP-Website.git","svn_url":"https://github.com/learning-unlimited/ESP-Website","homepage":"","size":58318,"stargazers_count":46,"watchers_count":46,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":502,"forks":34,"open_issues":502,"watchers":46,"default_branch":"main"}},"_links":{"self":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294"},"html":{"href":"https://github.com/learning-unlimited/ESP-Website/pull/1294"},"issue":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/1294"},"comments":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/issues/1294/comments"},"review_comments":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294/comments"},"review_comment":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/pulls/1294/commits"},"statuses":{"href":"https://api.github.com/repos/learning-unlimited/ESP-Website/statuses/745291d07b459070b34cfae4075130c0bc025689"}}}}