{"action":"created","comment":{"url":"https://api.github.com/repos/hhru/frontik/pulls/comments/24977710","id":24977710,"diff_hunk":"@@ -240,9 +192,47 @@ def __repr__(self):\n         return '{}.{}(<{} routes>)'.format(__package__, self.__class__.__name__, len(self.apps))\n \n \n-def build_frontik_app_dispatcher(frontik_app):\n+class FrontikApplication(tornado.web.Application):\n+    class DefaultConfig(object):\n+        pass\n \n-    def app_dispatcher(tornado_app, request, **kwargs):\n+    def __init__(self, **settings):\n+        tornado_settings = settings.get('tornado_settings', None)\n+\n+        if tornado_settings is None:\n+            tornado_settings = {}\n+\n+        super(FrontikApplication, self).__init__([\n+            (r'/version/?', VersionHandler),\n+            (r'/status/?', StatusHandler),\n+            (r'/stop/?', StopHandler),\n+            (r'/types_count/?', CountTypesHandler),\n+            (r'/pdb/?', PdbHandler),\n+            (r'/ph_count/?', CountPageHandlerInstancesHandler),\n+            (r'{}.*'.format(settings.get('app_root_url')), self.app_dispatcher),\n+        ], **tornado_settings)\n+\n+        self.config = self.application_config()\n+        self.app = settings.get('app')\n+        self.xml = frontik.producers.xml_producer.ApplicationXMLGlobals(self.config)","path":"frontik/app.py","position":135,"original_position":135,"commit_id":"12d08ff2947e6322cd0b952d23b87e61abee8837","original_commit_id":"12d08ff2947e6322cd0b952d23b87e61abee8837","user":{"login":"maizy","id":789623,"avatar_url":"https://avatars.githubusercontent.com/u/789623?v=3","gravatar_id":"","url":"https://api.github.com/users/maizy","html_url":"https://github.com/maizy","followers_url":"https://api.github.com/users/maizy/followers","following_url":"https://api.github.com/users/maizy/following{/other_user}","gists_url":"https://api.github.com/users/maizy/gists{/gist_id}","starred_url":"https://api.github.com/users/maizy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maizy/subscriptions","organizations_url":"https://api.github.com/users/maizy/orgs","repos_url":"https://api.github.com/users/maizy/repos","events_url":"https://api.github.com/users/maizy/events{/privacy}","received_events_url":"https://api.github.com/users/maizy/received_events","type":"User","site_admin":false},"body":"я бы разделил для гибкости эти инициализации на\r\n```\r\nself._init_producers()  # тут приложение при необходимости добавит своих producers\r\nself.curl_http_client = self._build_http_client()\r\nself.dispatcher = self._build_dispatcher()\r\n```\r\n\r\nвнутри _init_producers тоже можно сделать self._build_xml_producers, self._build_json_produces","created_at":"2015-02-19T10:21:29Z","updated_at":"2015-02-19T10:21:29Z","html_url":"https://github.com/hhru/frontik/pull/187#discussion_r24977710","pull_request_url":"https://api.github.com/repos/hhru/frontik/pulls/187","_links":{"self":{"href":"https://api.github.com/repos/hhru/frontik/pulls/comments/24977710"},"html":{"href":"https://github.com/hhru/frontik/pull/187#discussion_r24977710"},"pull_request":{"href":"https://api.github.com/repos/hhru/frontik/pulls/187"}}},"pull_request":{"url":"https://api.github.com/repos/hhru/frontik/pulls/187","id":29451795,"html_url":"https://github.com/hhru/frontik/pull/187","diff_url":"https://github.com/hhru/frontik/pull/187.diff","patch_url":"https://github.com/hhru/frontik/pull/187.patch","issue_url":"https://api.github.com/repos/hhru/frontik/issues/187","number":187,"state":"open","locked":false,"title":"HH-48942 Make frontik application initialisation similar to tornado application","user":{"login":"Aulust","id":532101,"avatar_url":"https://avatars.githubusercontent.com/u/532101?v=3","gravatar_id":"","url":"https://api.github.com/users/Aulust","html_url":"https://github.com/Aulust","followers_url":"https://api.github.com/users/Aulust/followers","following_url":"https://api.github.com/users/Aulust/following{/other_user}","gists_url":"https://api.github.com/users/Aulust/gists{/gist_id}","starred_url":"https://api.github.com/users/Aulust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aulust/subscriptions","organizations_url":"https://api.github.com/users/Aulust/orgs","repos_url":"https://api.github.com/users/Aulust/repos","events_url":"https://api.github.com/users/Aulust/events{/privacy}","received_events_url":"https://api.github.com/users/Aulust/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-17T15:44:16Z","updated_at":"2015-02-19T10:21:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c10598ca20aad3e0ccdc44df232b5214091b053","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hhru/frontik/pulls/187/commits","review_comments_url":"https://api.github.com/repos/hhru/frontik/pulls/187/comments","review_comment_url":"https://api.github.com/repos/hhru/frontik/pulls/comments/{number}","comments_url":"https://api.github.com/repos/hhru/frontik/issues/187/comments","statuses_url":"https://api.github.com/repos/hhru/frontik/statuses/12d08ff2947e6322cd0b952d23b87e61abee8837","head":{"label":"HH-48942","ref":"HH-48942","sha":"12d08ff2947e6322cd0b952d23b87e61abee8837","user":{"login":"hhru","id":152753,"avatar_url":"https://avatars.githubusercontent.com/u/152753?v=3","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"repo":{"id":825839,"name":"frontik","full_name":"hhru/frontik","owner":{"login":"hhru","id":152753,"avatar_url":"https://avatars.githubusercontent.com/u/152753?v=3","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hhru/frontik","description":"Maintainers: Сумин","fork":false,"url":"https://api.github.com/repos/hhru/frontik","forks_url":"https://api.github.com/repos/hhru/frontik/forks","keys_url":"https://api.github.com/repos/hhru/frontik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhru/frontik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhru/frontik/teams","hooks_url":"https://api.github.com/repos/hhru/frontik/hooks","issue_events_url":"https://api.github.com/repos/hhru/frontik/issues/events{/number}","events_url":"https://api.github.com/repos/hhru/frontik/events","assignees_url":"https://api.github.com/repos/hhru/frontik/assignees{/user}","branches_url":"https://api.github.com/repos/hhru/frontik/branches{/branch}","tags_url":"https://api.github.com/repos/hhru/frontik/tags","blobs_url":"https://api.github.com/repos/hhru/frontik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhru/frontik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhru/frontik/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhru/frontik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhru/frontik/statuses/{sha}","languages_url":"https://api.github.com/repos/hhru/frontik/languages","stargazers_url":"https://api.github.com/repos/hhru/frontik/stargazers","contributors_url":"https://api.github.com/repos/hhru/frontik/contributors","subscribers_url":"https://api.github.com/repos/hhru/frontik/subscribers","subscription_url":"https://api.github.com/repos/hhru/frontik/subscription","commits_url":"https://api.github.com/repos/hhru/frontik/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhru/frontik/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhru/frontik/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhru/frontik/issues/comments/{number}","contents_url":"https://api.github.com/repos/hhru/frontik/contents/{+path}","compare_url":"https://api.github.com/repos/hhru/frontik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhru/frontik/merges","archive_url":"https://api.github.com/repos/hhru/frontik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhru/frontik/downloads","issues_url":"https://api.github.com/repos/hhru/frontik/issues{/number}","pulls_url":"https://api.github.com/repos/hhru/frontik/pulls{/number}","milestones_url":"https://api.github.com/repos/hhru/frontik/milestones{/number}","notifications_url":"https://api.github.com/repos/hhru/frontik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhru/frontik/labels{/name}","releases_url":"https://api.github.com/repos/hhru/frontik/releases{/id}","created_at":"2010-08-09T05:13:13Z","updated_at":"2015-02-13T16:24:07Z","pushed_at":"2015-02-19T09:24:27Z","git_url":"git://github.com/hhru/frontik.git","ssh_url":"git@github.com:hhru/frontik.git","clone_url":"https://github.com/hhru/frontik.git","svn_url":"https://github.com/hhru/frontik","homepage":"","size":8186,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":28,"default_branch":"master"}},"base":{"label":"master","ref":"master","sha":"4e45fff53497cc3ae6f6352e093e288ecda1adb5","user":{"login":"hhru","id":152753,"avatar_url":"https://avatars.githubusercontent.com/u/152753?v=3","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"repo":{"id":825839,"name":"frontik","full_name":"hhru/frontik","owner":{"login":"hhru","id":152753,"avatar_url":"https://avatars.githubusercontent.com/u/152753?v=3","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hhru/frontik","description":"Maintainers: Сумин","fork":false,"url":"https://api.github.com/repos/hhru/frontik","forks_url":"https://api.github.com/repos/hhru/frontik/forks","keys_url":"https://api.github.com/repos/hhru/frontik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhru/frontik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhru/frontik/teams","hooks_url":"https://api.github.com/repos/hhru/frontik/hooks","issue_events_url":"https://api.github.com/repos/hhru/frontik/issues/events{/number}","events_url":"https://api.github.com/repos/hhru/frontik/events","assignees_url":"https://api.github.com/repos/hhru/frontik/assignees{/user}","branches_url":"https://api.github.com/repos/hhru/frontik/branches{/branch}","tags_url":"https://api.github.com/repos/hhru/frontik/tags","blobs_url":"https://api.github.com/repos/hhru/frontik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhru/frontik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhru/frontik/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhru/frontik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhru/frontik/statuses/{sha}","languages_url":"https://api.github.com/repos/hhru/frontik/languages","stargazers_url":"https://api.github.com/repos/hhru/frontik/stargazers","contributors_url":"https://api.github.com/repos/hhru/frontik/contributors","subscribers_url":"https://api.github.com/repos/hhru/frontik/subscribers","subscription_url":"https://api.github.com/repos/hhru/frontik/subscription","commits_url":"https://api.github.com/repos/hhru/frontik/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhru/frontik/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhru/frontik/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhru/frontik/issues/comments/{number}","contents_url":"https://api.github.com/repos/hhru/frontik/contents/{+path}","compare_url":"https://api.github.com/repos/hhru/frontik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhru/frontik/merges","archive_url":"https://api.github.com/repos/hhru/frontik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhru/frontik/downloads","issues_url":"https://api.github.com/repos/hhru/frontik/issues{/number}","pulls_url":"https://api.github.com/repos/hhru/frontik/pulls{/number}","milestones_url":"https://api.github.com/repos/hhru/frontik/milestones{/number}","notifications_url":"https://api.github.com/repos/hhru/frontik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhru/frontik/labels{/name}","releases_url":"https://api.github.com/repos/hhru/frontik/releases{/id}","created_at":"2010-08-09T05:13:13Z","updated_at":"2015-02-13T16:24:07Z","pushed_at":"2015-02-19T09:24:27Z","git_url":"git://github.com/hhru/frontik.git","ssh_url":"git@github.com:hhru/frontik.git","clone_url":"https://github.com/hhru/frontik.git","svn_url":"https://github.com/hhru/frontik","homepage":"","size":8186,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hhru/frontik/pulls/187"},"html":{"href":"https://github.com/hhru/frontik/pull/187"},"issue":{"href":"https://api.github.com/repos/hhru/frontik/issues/187"},"comments":{"href":"https://api.github.com/repos/hhru/frontik/issues/187/comments"},"review_comments":{"href":"https://api.github.com/repos/hhru/frontik/pulls/187/comments"},"review_comment":{"href":"https://api.github.com/repos/hhru/frontik/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/hhru/frontik/pulls/187/commits"},"statuses":{"href":"https://api.github.com/repos/hhru/frontik/statuses/12d08ff2947e6322cd0b952d23b87e61abee8837"}}}}