{"action":"created","comment":{"url":"https://api.github.com/repos/dendgau/guestbook/pulls/comments/34861408","id":34861408,"diff_hunk":"@@ -0,0 +1,200 @@\n+# -*- coding: utf-8 -*-\n+import datetime\n+import importlib\n+\n+from django import http\n+from django.http import QueryDict\n+from django.utils import simplejson as json\n+from django.views.generic.edit import BaseFormView\n+from django.http import HttpResponse\n+\n+from google.appengine.api import users\n+\n+from guestbook_app.models import AppConstants\n+\n+GUESTBOOK_DEFAULT = AppConstants.get_default_guestbook_name()\n+\n+\n+def _execute_service(view, method_name, **param):\n+\tsvc = view.get_service()\n+\tkwargs = view.kwargs.copy()\n+\tkwargs.update(param)\n+\n+\tmethod = getattr(svc, method_name, None)\n+\tif method and callable(method):\n+\t\ttry:\n+\t\t\treturn method(**kwargs)\n+\t\texcept NotImplementedError:\n+\t\t\traise NotImplementedError(\"Can't found method in class\")\n+\n+\n+class JSONResponseMixin(object):\n+\tdef render_to_response(self, context):\n+\t\treturn self.get_json_response(self.convert_context_to_json(context))\n+\n+\t@staticmethod\n+\tdef get_json_response(content, **http_response_kwargs):\n+\t\treturn http.HttpResponse(content, content_type='application/json', **http_response_kwargs)\n+\n+\t@staticmethod\n+\tdef convert_context_to_json(context):\n+\t\treturn json.dumps(context)\n+\n+\n+class GreetingViewBase(JSONResponseMixin, BaseFormView):\n+\tservice_name = None\n+\n+\tdef get_service(self):\n+\t\tmodule_name = self.service_name.split(\"Service\")[0]\n+\t\tmodule_name = module_name.lower()\n+\t\tservices_module = '.'.join((\"guestbook_app\", \"api\", \"services\", module_name))\n+\t\ttry:\n+\t\t\timport_module = importlib.import_module(services_module)\n+\t\texcept ImportError:\n+\t\t\traise ImportError(\"Can't found module name\")\n+\n+\t\ttry:\n+\t\t\timport_class = getattr(import_module, self.service_name)\n+\t\texcept AttributeError:\n+\t\t\traise AttributeError(\"Can't found class name\")\n+\n+\t\treturn import_class\n+\n+\tdef list_resources(self, **param):\n+\t\treturn _execute_service(self, 'list', **param)\n+\n+\tdef get_resources(self, **param):\n+\t\treturn _execute_service(self, 'get', **param)\n+\n+\tdef create_resources(self, **param):","path":"guestbook_app/api/restful.py","position":69,"original_position":69,"commit_id":"00661c18aeb489aeaae03dd53040df8352f60c5f","original_commit_id":"00661c18aeb489aeaae03dd53040df8352f60c5f","user":{"login":"phucnpm","id":7623464,"avatar_url":"https://avatars.githubusercontent.com/u/7623464?v=3","gravatar_id":"","url":"https://api.github.com/users/phucnpm","html_url":"https://github.com/phucnpm","followers_url":"https://api.github.com/users/phucnpm/followers","following_url":"https://api.github.com/users/phucnpm/following{/other_user}","gists_url":"https://api.github.com/users/phucnpm/gists{/gist_id}","starred_url":"https://api.github.com/users/phucnpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phucnpm/subscriptions","organizations_url":"https://api.github.com/users/phucnpm/orgs","repos_url":"https://api.github.com/users/phucnpm/repos","events_url":"https://api.github.com/users/phucnpm/events{/privacy}","received_events_url":"https://api.github.com/users/phucnpm/received_events","type":"User","site_admin":false},"body":"các thao tác list, get, create, update, delete gộp hết thành Base là không đúng vì \r\n- GreetingView không xài tới create, update, delete\r\n- GreetingDetailView không xài tới list \r\n\r\nnếu muốn xài y chang design của rakumo thì hãy đặt tên common nhất có thể, nó k0 chỉ xài riêng cho guestbook or greeting ( giữ lại tên class của họ cho nhanh )\r\n- CollectionResourceView : dùng để handle các api /greetings/\r\n- SingleResourceView : dùng để handle các api /greetings/<id>/","created_at":"2015-07-17T04:28:05Z","updated_at":"2015-07-17T04:28:05Z","html_url":"https://github.com/dendgau/guestbook/pull/11#discussion_r34861408","pull_request_url":"https://api.github.com/repos/dendgau/guestbook/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/dendgau/guestbook/pulls/comments/34861408"},"html":{"href":"https://github.com/dendgau/guestbook/pull/11#discussion_r34861408"},"pull_request":{"href":"https://api.github.com/repos/dendgau/guestbook/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/dendgau/guestbook/pulls/11","id":40117740,"html_url":"https://github.com/dendgau/guestbook/pull/11","diff_url":"https://github.com/dendgau/guestbook/pull/11.diff","patch_url":"https://github.com/dendgau/guestbook/pull/11.patch","issue_url":"https://api.github.com/repos/dendgau/guestbook/issues/11","number":11,"state":"open","locked":false,"title":"Advance services","user":{"login":"dendgau","id":6759698,"avatar_url":"https://avatars.githubusercontent.com/u/6759698?v=3","gravatar_id":"","url":"https://api.github.com/users/dendgau","html_url":"https://github.com/dendgau","followers_url":"https://api.github.com/users/dendgau/followers","following_url":"https://api.github.com/users/dendgau/following{/other_user}","gists_url":"https://api.github.com/users/dendgau/gists{/gist_id}","starred_url":"https://api.github.com/users/dendgau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendgau/subscriptions","organizations_url":"https://api.github.com/users/dendgau/orgs","repos_url":"https://api.github.com/users/dendgau/repos","events_url":"https://api.github.com/users/dendgau/events{/privacy}","received_events_url":"https://api.github.com/users/dendgau/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-16T11:05:43Z","updated_at":"2015-07-17T04:28:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d70048daf809462159c6f4c59e7e4e7fb6986152","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dendgau/guestbook/pulls/11/commits","review_comments_url":"https://api.github.com/repos/dendgau/guestbook/pulls/11/comments","review_comment_url":"https://api.github.com/repos/dendgau/guestbook/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dendgau/guestbook/issues/11/comments","statuses_url":"https://api.github.com/repos/dendgau/guestbook/statuses/00661c18aeb489aeaae03dd53040df8352f60c5f","head":{"label":"dendgau:feature/advanced_service","ref":"feature/advanced_service","sha":"00661c18aeb489aeaae03dd53040df8352f60c5f","user":{"login":"dendgau","id":6759698,"avatar_url":"https://avatars.githubusercontent.com/u/6759698?v=3","gravatar_id":"","url":"https://api.github.com/users/dendgau","html_url":"https://github.com/dendgau","followers_url":"https://api.github.com/users/dendgau/followers","following_url":"https://api.github.com/users/dendgau/following{/other_user}","gists_url":"https://api.github.com/users/dendgau/gists{/gist_id}","starred_url":"https://api.github.com/users/dendgau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendgau/subscriptions","organizations_url":"https://api.github.com/users/dendgau/orgs","repos_url":"https://api.github.com/users/dendgau/repos","events_url":"https://api.github.com/users/dendgau/events{/privacy}","received_events_url":"https://api.github.com/users/dendgau/received_events","type":"User","site_admin":false},"repo":{"id":30630355,"name":"guestbook","full_name":"dendgau/guestbook","owner":{"login":"dendgau","id":6759698,"avatar_url":"https://avatars.githubusercontent.com/u/6759698?v=3","gravatar_id":"","url":"https://api.github.com/users/dendgau","html_url":"https://github.com/dendgau","followers_url":"https://api.github.com/users/dendgau/followers","following_url":"https://api.github.com/users/dendgau/following{/other_user}","gists_url":"https://api.github.com/users/dendgau/gists{/gist_id}","starred_url":"https://api.github.com/users/dendgau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendgau/subscriptions","organizations_url":"https://api.github.com/users/dendgau/orgs","repos_url":"https://api.github.com/users/dendgau/repos","events_url":"https://api.github.com/users/dendgau/events{/privacy}","received_events_url":"https://api.github.com/users/dendgau/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dendgau/guestbook","description":"Build guestbook app","fork":false,"url":"https://api.github.com/repos/dendgau/guestbook","forks_url":"https://api.github.com/repos/dendgau/guestbook/forks","keys_url":"https://api.github.com/repos/dendgau/guestbook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dendgau/guestbook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dendgau/guestbook/teams","hooks_url":"https://api.github.com/repos/dendgau/guestbook/hooks","issue_events_url":"https://api.github.com/repos/dendgau/guestbook/issues/events{/number}","events_url":"https://api.github.com/repos/dendgau/guestbook/events","assignees_url":"https://api.github.com/repos/dendgau/guestbook/assignees{/user}","branches_url":"https://api.github.com/repos/dendgau/guestbook/branches{/branch}","tags_url":"https://api.github.com/repos/dendgau/guestbook/tags","blobs_url":"https://api.github.com/repos/dendgau/guestbook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dendgau/guestbook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dendgau/guestbook/git/refs{/sha}","trees_url":"https://api.github.com/repos/dendgau/guestbook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dendgau/guestbook/statuses/{sha}","languages_url":"https://api.github.com/repos/dendgau/guestbook/languages","stargazers_url":"https://api.github.com/repos/dendgau/guestbook/stargazers","contributors_url":"https://api.github.com/repos/dendgau/guestbook/contributors","subscribers_url":"https://api.github.com/repos/dendgau/guestbook/subscribers","subscription_url":"https://api.github.com/repos/dendgau/guestbook/subscription","commits_url":"https://api.github.com/repos/dendgau/guestbook/commits{/sha}","git_commits_url":"https://api.github.com/repos/dendgau/guestbook/git/commits{/sha}","comments_url":"https://api.github.com/repos/dendgau/guestbook/comments{/number}","issue_comment_url":"https://api.github.com/repos/dendgau/guestbook/issues/comments{/number}","contents_url":"https://api.github.com/repos/dendgau/guestbook/contents/{+path}","compare_url":"https://api.github.com/repos/dendgau/guestbook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dendgau/guestbook/merges","archive_url":"https://api.github.com/repos/dendgau/guestbook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dendgau/guestbook/downloads","issues_url":"https://api.github.com/repos/dendgau/guestbook/issues{/number}","pulls_url":"https://api.github.com/repos/dendgau/guestbook/pulls{/number}","milestones_url":"https://api.github.com/repos/dendgau/guestbook/milestones{/number}","notifications_url":"https://api.github.com/repos/dendgau/guestbook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dendgau/guestbook/labels{/name}","releases_url":"https://api.github.com/repos/dendgau/guestbook/releases{/id}","created_at":"2015-02-11T04:21:43Z","updated_at":"2015-02-11T06:40:47Z","pushed_at":"2015-07-17T03:51:03Z","git_url":"git://github.com/dendgau/guestbook.git","ssh_url":"git@github.com:dendgau/guestbook.git","clone_url":"https://github.com/dendgau/guestbook.git","svn_url":"https://github.com/dendgau/guestbook","homepage":null,"size":428,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"dendgau:develop","ref":"develop","sha":"1118e9e47f0e14af460915fdb678c6ed862ed07d","user":{"login":"dendgau","id":6759698,"avatar_url":"https://avatars.githubusercontent.com/u/6759698?v=3","gravatar_id":"","url":"https://api.github.com/users/dendgau","html_url":"https://github.com/dendgau","followers_url":"https://api.github.com/users/dendgau/followers","following_url":"https://api.github.com/users/dendgau/following{/other_user}","gists_url":"https://api.github.com/users/dendgau/gists{/gist_id}","starred_url":"https://api.github.com/users/dendgau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendgau/subscriptions","organizations_url":"https://api.github.com/users/dendgau/orgs","repos_url":"https://api.github.com/users/dendgau/repos","events_url":"https://api.github.com/users/dendgau/events{/privacy}","received_events_url":"https://api.github.com/users/dendgau/received_events","type":"User","site_admin":false},"repo":{"id":30630355,"name":"guestbook","full_name":"dendgau/guestbook","owner":{"login":"dendgau","id":6759698,"avatar_url":"https://avatars.githubusercontent.com/u/6759698?v=3","gravatar_id":"","url":"https://api.github.com/users/dendgau","html_url":"https://github.com/dendgau","followers_url":"https://api.github.com/users/dendgau/followers","following_url":"https://api.github.com/users/dendgau/following{/other_user}","gists_url":"https://api.github.com/users/dendgau/gists{/gist_id}","starred_url":"https://api.github.com/users/dendgau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendgau/subscriptions","organizations_url":"https://api.github.com/users/dendgau/orgs","repos_url":"https://api.github.com/users/dendgau/repos","events_url":"https://api.github.com/users/dendgau/events{/privacy}","received_events_url":"https://api.github.com/users/dendgau/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dendgau/guestbook","description":"Build guestbook app","fork":false,"url":"https://api.github.com/repos/dendgau/guestbook","forks_url":"https://api.github.com/repos/dendgau/guestbook/forks","keys_url":"https://api.github.com/repos/dendgau/guestbook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dendgau/guestbook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dendgau/guestbook/teams","hooks_url":"https://api.github.com/repos/dendgau/guestbook/hooks","issue_events_url":"https://api.github.com/repos/dendgau/guestbook/issues/events{/number}","events_url":"https://api.github.com/repos/dendgau/guestbook/events","assignees_url":"https://api.github.com/repos/dendgau/guestbook/assignees{/user}","branches_url":"https://api.github.com/repos/dendgau/guestbook/branches{/branch}","tags_url":"https://api.github.com/repos/dendgau/guestbook/tags","blobs_url":"https://api.github.com/repos/dendgau/guestbook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dendgau/guestbook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dendgau/guestbook/git/refs{/sha}","trees_url":"https://api.github.com/repos/dendgau/guestbook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dendgau/guestbook/statuses/{sha}","languages_url":"https://api.github.com/repos/dendgau/guestbook/languages","stargazers_url":"https://api.github.com/repos/dendgau/guestbook/stargazers","contributors_url":"https://api.github.com/repos/dendgau/guestbook/contributors","subscribers_url":"https://api.github.com/repos/dendgau/guestbook/subscribers","subscription_url":"https://api.github.com/repos/dendgau/guestbook/subscription","commits_url":"https://api.github.com/repos/dendgau/guestbook/commits{/sha}","git_commits_url":"https://api.github.com/repos/dendgau/guestbook/git/commits{/sha}","comments_url":"https://api.github.com/repos/dendgau/guestbook/comments{/number}","issue_comment_url":"https://api.github.com/repos/dendgau/guestbook/issues/comments{/number}","contents_url":"https://api.github.com/repos/dendgau/guestbook/contents/{+path}","compare_url":"https://api.github.com/repos/dendgau/guestbook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dendgau/guestbook/merges","archive_url":"https://api.github.com/repos/dendgau/guestbook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dendgau/guestbook/downloads","issues_url":"https://api.github.com/repos/dendgau/guestbook/issues{/number}","pulls_url":"https://api.github.com/repos/dendgau/guestbook/pulls{/number}","milestones_url":"https://api.github.com/repos/dendgau/guestbook/milestones{/number}","notifications_url":"https://api.github.com/repos/dendgau/guestbook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dendgau/guestbook/labels{/name}","releases_url":"https://api.github.com/repos/dendgau/guestbook/releases{/id}","created_at":"2015-02-11T04:21:43Z","updated_at":"2015-02-11T06:40:47Z","pushed_at":"2015-07-17T03:51:03Z","git_url":"git://github.com/dendgau/guestbook.git","ssh_url":"git@github.com:dendgau/guestbook.git","clone_url":"https://github.com/dendgau/guestbook.git","svn_url":"https://github.com/dendgau/guestbook","homepage":null,"size":428,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dendgau/guestbook/pulls/11"},"html":{"href":"https://github.com/dendgau/guestbook/pull/11"},"issue":{"href":"https://api.github.com/repos/dendgau/guestbook/issues/11"},"comments":{"href":"https://api.github.com/repos/dendgau/guestbook/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/dendgau/guestbook/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/dendgau/guestbook/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dendgau/guestbook/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/dendgau/guestbook/statuses/00661c18aeb489aeaae03dd53040df8352f60c5f"}}}}