Show More
@@ -1,154 +1,154 b'' | |||||
1 |
|
1 | |||
2 | /****************************************************************************** |
|
2 | /****************************************************************************** | |
3 | * * |
|
3 | * * | |
4 | * DO NOT CHANGE THIS FILE MANUALLY * |
|
4 | * DO NOT CHANGE THIS FILE MANUALLY * | |
5 | * * |
|
5 | * * | |
6 | * * |
|
6 | * * | |
7 | * This file is automatically generated when the app starts up with * |
|
7 | * This file is automatically generated when the app starts up with * | |
8 | * generate_js_files = true * |
|
8 | * generate_js_files = true * | |
9 | * * |
|
9 | * * | |
10 | * To add a route here pass jsroute=True to the route definition in the app * |
|
10 | * To add a route here pass jsroute=True to the route definition in the app * | |
11 | * * |
|
11 | * * | |
12 | ******************************************************************************/ |
|
12 | ******************************************************************************/ | |
13 | function registerRCRoutes() { |
|
13 | function registerRCRoutes() { | |
14 | // routes registration |
|
14 | // routes registration | |
15 | pyroutes.register('new_repo', '/_admin/create_repository', []); |
|
15 | pyroutes.register('new_repo', '/_admin/create_repository', []); | |
16 | pyroutes.register('edit_user', '/_admin/users/%(user_id)s/edit', ['user_id']); |
|
16 | pyroutes.register('edit_user', '/_admin/users/%(user_id)s/edit', ['user_id']); | |
17 | pyroutes.register('edit_user_group_members', '/_admin/user_groups/%(user_group_id)s/edit/members', ['user_group_id']); |
|
17 | pyroutes.register('edit_user_group_members', '/_admin/user_groups/%(user_group_id)s/edit/members', ['user_group_id']); | |
18 | pyroutes.register('gists', '/_admin/gists', []); |
|
18 | pyroutes.register('gists', '/_admin/gists', []); | |
19 | pyroutes.register('new_gist', '/_admin/gists/new', []); |
|
19 | pyroutes.register('new_gist', '/_admin/gists/new', []); | |
20 | pyroutes.register('toggle_following', '/_admin/toggle_following', []); |
|
20 | pyroutes.register('toggle_following', '/_admin/toggle_following', []); | |
21 | pyroutes.register('changeset_home', '/%(repo_name)s/changeset/%(revision)s', ['repo_name', 'revision']); |
|
21 | pyroutes.register('changeset_home', '/%(repo_name)s/changeset/%(revision)s', ['repo_name', 'revision']); | |
22 | pyroutes.register('changeset_comment', '/%(repo_name)s/changeset/%(revision)s/comment', ['repo_name', 'revision']); |
|
22 | pyroutes.register('changeset_comment', '/%(repo_name)s/changeset/%(revision)s/comment', ['repo_name', 'revision']); | |
23 | pyroutes.register('changeset_comment_preview', '/%(repo_name)s/changeset/comment/preview', ['repo_name']); |
|
23 | pyroutes.register('changeset_comment_preview', '/%(repo_name)s/changeset/comment/preview', ['repo_name']); | |
24 | pyroutes.register('changeset_comment_delete', '/%(repo_name)s/changeset/comment/%(comment_id)s/delete', ['repo_name', 'comment_id']); |
|
24 | pyroutes.register('changeset_comment_delete', '/%(repo_name)s/changeset/comment/%(comment_id)s/delete', ['repo_name', 'comment_id']); | |
25 | pyroutes.register('changeset_info', '/%(repo_name)s/changeset_info/%(revision)s', ['repo_name', 'revision']); |
|
25 | pyroutes.register('changeset_info', '/%(repo_name)s/changeset_info/%(revision)s', ['repo_name', 'revision']); | |
26 | pyroutes.register('compare_url', '/%(repo_name)s/compare/%(source_ref_type)s@%(source_ref)s...%(target_ref_type)s@%(target_ref)s', ['repo_name', 'source_ref_type', 'source_ref', 'target_ref_type', 'target_ref']); |
|
26 | pyroutes.register('compare_url', '/%(repo_name)s/compare/%(source_ref_type)s@%(source_ref)s...%(target_ref_type)s@%(target_ref)s', ['repo_name', 'source_ref_type', 'source_ref', 'target_ref_type', 'target_ref']); | |
27 | pyroutes.register('pullrequest_home', '/%(repo_name)s/pull-request/new', ['repo_name']); |
|
27 | pyroutes.register('pullrequest_home', '/%(repo_name)s/pull-request/new', ['repo_name']); | |
28 | pyroutes.register('pullrequest', '/%(repo_name)s/pull-request/new', ['repo_name']); |
|
28 | pyroutes.register('pullrequest', '/%(repo_name)s/pull-request/new', ['repo_name']); | |
29 | pyroutes.register('pullrequest_repo_refs', '/%(repo_name)s/pull-request/refs/%(target_repo_name)s', ['repo_name', 'target_repo_name']); |
|
29 | pyroutes.register('pullrequest_repo_refs', '/%(repo_name)s/pull-request/refs/%(target_repo_name)s', ['repo_name', 'target_repo_name']); | |
30 | pyroutes.register('pullrequest_repo_destinations', '/%(repo_name)s/pull-request/repo-destinations', ['repo_name']); |
|
30 | pyroutes.register('pullrequest_repo_destinations', '/%(repo_name)s/pull-request/repo-destinations', ['repo_name']); | |
31 | pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']); |
|
31 | pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']); | |
32 | pyroutes.register('pullrequest_update', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']); |
|
32 | pyroutes.register('pullrequest_update', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']); | |
33 | pyroutes.register('pullrequest_comment', '/%(repo_name)s/pull-request-comment/%(pull_request_id)s', ['repo_name', 'pull_request_id']); |
|
33 | pyroutes.register('pullrequest_comment', '/%(repo_name)s/pull-request-comment/%(pull_request_id)s', ['repo_name', 'pull_request_id']); | |
34 | pyroutes.register('pullrequest_comment_delete', '/%(repo_name)s/pull-request-comment/%(comment_id)s/delete', ['repo_name', 'comment_id']); |
|
34 | pyroutes.register('pullrequest_comment_delete', '/%(repo_name)s/pull-request-comment/%(comment_id)s/delete', ['repo_name', 'comment_id']); | |
35 | pyroutes.register('changelog_home', '/%(repo_name)s/changelog', ['repo_name']); |
|
35 | pyroutes.register('changelog_home', '/%(repo_name)s/changelog', ['repo_name']); | |
36 | pyroutes.register('changelog_file_home', '/%(repo_name)s/changelog/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
36 | pyroutes.register('changelog_file_home', '/%(repo_name)s/changelog/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
37 | pyroutes.register('changelog_elements', '/%(repo_name)s/changelog_details', ['repo_name']); |
|
37 | pyroutes.register('changelog_elements', '/%(repo_name)s/changelog_details', ['repo_name']); | |
38 | pyroutes.register('files_home', '/%(repo_name)s/files/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
38 | pyroutes.register('files_home', '/%(repo_name)s/files/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
39 | pyroutes.register('files_history_home', '/%(repo_name)s/history/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
39 | pyroutes.register('files_history_home', '/%(repo_name)s/history/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
40 | pyroutes.register('files_authors_home', '/%(repo_name)s/authors/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
40 | pyroutes.register('files_authors_home', '/%(repo_name)s/authors/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
41 | pyroutes.register('files_annotate_home', '/%(repo_name)s/annotate/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
41 | pyroutes.register('files_annotate_home', '/%(repo_name)s/annotate/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
42 | pyroutes.register('files_annotate_previous', '/%(repo_name)s/annotate-previous/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
42 | pyroutes.register('files_annotate_previous', '/%(repo_name)s/annotate-previous/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
43 | pyroutes.register('files_archive_home', '/%(repo_name)s/archive/%(fname)s', ['repo_name', 'fname']); |
|
43 | pyroutes.register('files_archive_home', '/%(repo_name)s/archive/%(fname)s', ['repo_name', 'fname']); | |
44 | pyroutes.register('files_nodelist_home', '/%(repo_name)s/nodelist/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); |
|
44 | pyroutes.register('files_nodelist_home', '/%(repo_name)s/nodelist/%(revision)s/%(f_path)s', ['repo_name', 'revision', 'f_path']); | |
45 | pyroutes.register('files_nodetree_full', '/%(repo_name)s/nodetree_full/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); |
|
45 | pyroutes.register('files_nodetree_full', '/%(repo_name)s/nodetree_full/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); | |
46 | pyroutes.register('favicon', '/favicon.ico', []); |
|
46 | pyroutes.register('favicon', '/favicon.ico', []); | |
47 | pyroutes.register('robots', '/robots.txt', []); |
|
47 | pyroutes.register('robots', '/robots.txt', []); | |
48 | pyroutes.register('auth_home', '/_admin/auth*traverse', []); |
|
48 | pyroutes.register('auth_home', '/_admin/auth*traverse', []); | |
49 | pyroutes.register('global_integrations_new', '/_admin/integrations/new', []); |
|
49 | pyroutes.register('global_integrations_new', '/_admin/integrations/new', []); | |
50 | pyroutes.register('global_integrations_home', '/_admin/integrations', []); |
|
50 | pyroutes.register('global_integrations_home', '/_admin/integrations', []); | |
51 | pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']); |
|
51 | pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']); | |
52 | pyroutes.register('global_integrations_create', '/_admin/integrations/%(integration)s/new', ['integration']); |
|
52 | pyroutes.register('global_integrations_create', '/_admin/integrations/%(integration)s/new', ['integration']); | |
53 | pyroutes.register('global_integrations_edit', '/_admin/integrations/%(integration)s/%(integration_id)s', ['integration', 'integration_id']); |
|
53 | pyroutes.register('global_integrations_edit', '/_admin/integrations/%(integration)s/%(integration_id)s', ['integration', 'integration_id']); | |
54 | pyroutes.register('repo_group_integrations_home', '%(repo_group_name)s/settings/integrations', ['repo_group_name']); |
|
54 | pyroutes.register('repo_group_integrations_home', '/%(repo_group_name)s/settings/integrations', ['repo_group_name']); | |
55 | pyroutes.register('repo_group_integrations_list', '%(repo_group_name)s/settings/integrations/%(integration)s', ['repo_group_name', 'integration']); |
|
55 | pyroutes.register('repo_group_integrations_list', '/%(repo_group_name)s/settings/integrations/%(integration)s', ['repo_group_name', 'integration']); | |
56 | pyroutes.register('repo_group_integrations_new', '%(repo_group_name)s/settings/integrations/new', ['repo_group_name']); |
|
56 | pyroutes.register('repo_group_integrations_new', '/%(repo_group_name)s/settings/integrations/new', ['repo_group_name']); | |
57 | pyroutes.register('repo_group_integrations_create', '%(repo_group_name)s/settings/integrations/%(integration)s/new', ['repo_group_name', 'integration']); |
|
57 | pyroutes.register('repo_group_integrations_create', '/%(repo_group_name)s/settings/integrations/%(integration)s/new', ['repo_group_name', 'integration']); | |
58 | pyroutes.register('repo_group_integrations_edit', '%(repo_group_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_group_name', 'integration', 'integration_id']); |
|
58 | pyroutes.register('repo_group_integrations_edit', '/%(repo_group_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_group_name', 'integration', 'integration_id']); | |
59 | pyroutes.register('repo_integrations_home', '%(repo_name)s/settings/integrations', ['repo_name']); |
|
59 | pyroutes.register('repo_integrations_home', '/%(repo_name)s/settings/integrations', ['repo_name']); | |
60 | pyroutes.register('repo_integrations_list', '%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']); |
|
60 | pyroutes.register('repo_integrations_list', '/%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']); | |
61 | pyroutes.register('repo_integrations_new', '%(repo_name)s/settings/integrations/new', ['repo_name']); |
|
61 | pyroutes.register('repo_integrations_new', '/%(repo_name)s/settings/integrations/new', ['repo_name']); | |
62 | pyroutes.register('repo_integrations_create', '%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']); |
|
62 | pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']); | |
63 | pyroutes.register('repo_integrations_edit', '%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']); |
|
63 | pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']); | |
64 | pyroutes.register('ops_ping', '_admin/ops/ping', []); |
|
64 | pyroutes.register('ops_ping', '/_admin/ops/ping', []); | |
65 | pyroutes.register('admin_home', '/_admin', []); |
|
65 | pyroutes.register('admin_home', '/_admin', []); | |
66 | pyroutes.register('admin_audit_logs', '_admin/audit_logs', []); |
|
66 | pyroutes.register('admin_audit_logs', '/_admin/audit_logs', []); | |
67 | pyroutes.register('pull_requests_global_0', '_admin/pull_requests/%(pull_request_id)s', ['pull_request_id']); |
|
67 | pyroutes.register('pull_requests_global_0', '/_admin/pull_requests/%(pull_request_id)s', ['pull_request_id']); | |
68 | pyroutes.register('pull_requests_global_1', '_admin/pull-requests/%(pull_request_id)s', ['pull_request_id']); |
|
68 | pyroutes.register('pull_requests_global_1', '/_admin/pull-requests/%(pull_request_id)s', ['pull_request_id']); | |
69 | pyroutes.register('pull_requests_global', '_admin/pull-request/%(pull_request_id)s', ['pull_request_id']); |
|
69 | pyroutes.register('pull_requests_global', '/_admin/pull-request/%(pull_request_id)s', ['pull_request_id']); | |
70 | pyroutes.register('admin_settings_open_source', '_admin/settings/open_source', []); |
|
70 | pyroutes.register('admin_settings_open_source', '/_admin/settings/open_source', []); | |
71 | pyroutes.register('admin_settings_vcs_svn_generate_cfg', '_admin/settings/vcs/svn_generate_cfg', []); |
|
71 | pyroutes.register('admin_settings_vcs_svn_generate_cfg', '/_admin/settings/vcs/svn_generate_cfg', []); | |
72 | pyroutes.register('admin_settings_system', '_admin/settings/system', []); |
|
72 | pyroutes.register('admin_settings_system', '/_admin/settings/system', []); | |
73 | pyroutes.register('admin_settings_system_update', '_admin/settings/system/updates', []); |
|
73 | pyroutes.register('admin_settings_system_update', '/_admin/settings/system/updates', []); | |
74 | pyroutes.register('admin_settings_sessions', '_admin/settings/sessions', []); |
|
74 | pyroutes.register('admin_settings_sessions', '/_admin/settings/sessions', []); | |
75 | pyroutes.register('admin_settings_sessions_cleanup', '_admin/settings/sessions/cleanup', []); |
|
75 | pyroutes.register('admin_settings_sessions_cleanup', '/_admin/settings/sessions/cleanup', []); | |
76 | pyroutes.register('admin_permissions_ips', '_admin/permissions/ips', []); |
|
76 | pyroutes.register('admin_permissions_ips', '/_admin/permissions/ips', []); | |
77 | pyroutes.register('users', '_admin/users', []); |
|
77 | pyroutes.register('users', '/_admin/users', []); | |
78 | pyroutes.register('users_data', '_admin/users_data', []); |
|
78 | pyroutes.register('users_data', '/_admin/users_data', []); | |
79 | pyroutes.register('edit_user_auth_tokens', '_admin/users/%(user_id)s/edit/auth_tokens', ['user_id']); |
|
79 | pyroutes.register('edit_user_auth_tokens', '/_admin/users/%(user_id)s/edit/auth_tokens', ['user_id']); | |
80 | pyroutes.register('edit_user_auth_tokens_add', '_admin/users/%(user_id)s/edit/auth_tokens/new', ['user_id']); |
|
80 | pyroutes.register('edit_user_auth_tokens_add', '/_admin/users/%(user_id)s/edit/auth_tokens/new', ['user_id']); | |
81 | pyroutes.register('edit_user_auth_tokens_delete', '_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']); |
|
81 | pyroutes.register('edit_user_auth_tokens_delete', '/_admin/users/%(user_id)s/edit/auth_tokens/delete', ['user_id']); | |
82 | pyroutes.register('edit_user_emails', '_admin/users/%(user_id)s/edit/emails', ['user_id']); |
|
82 | pyroutes.register('edit_user_emails', '/_admin/users/%(user_id)s/edit/emails', ['user_id']); | |
83 | pyroutes.register('edit_user_emails_add', '_admin/users/%(user_id)s/edit/emails/new', ['user_id']); |
|
83 | pyroutes.register('edit_user_emails_add', '/_admin/users/%(user_id)s/edit/emails/new', ['user_id']); | |
84 | pyroutes.register('edit_user_emails_delete', '_admin/users/%(user_id)s/edit/emails/delete', ['user_id']); |
|
84 | pyroutes.register('edit_user_emails_delete', '/_admin/users/%(user_id)s/edit/emails/delete', ['user_id']); | |
85 | pyroutes.register('edit_user_ips', '_admin/users/%(user_id)s/edit/ips', ['user_id']); |
|
85 | pyroutes.register('edit_user_ips', '/_admin/users/%(user_id)s/edit/ips', ['user_id']); | |
86 | pyroutes.register('edit_user_ips_add', '_admin/users/%(user_id)s/edit/ips/new', ['user_id']); |
|
86 | pyroutes.register('edit_user_ips_add', '/_admin/users/%(user_id)s/edit/ips/new', ['user_id']); | |
87 | pyroutes.register('edit_user_ips_delete', '_admin/users/%(user_id)s/edit/ips/delete', ['user_id']); |
|
87 | pyroutes.register('edit_user_ips_delete', '/_admin/users/%(user_id)s/edit/ips/delete', ['user_id']); | |
88 | pyroutes.register('edit_user_groups_management', '_admin/users/%(user_id)s/edit/groups_management', ['user_id']); |
|
88 | pyroutes.register('edit_user_groups_management', '/_admin/users/%(user_id)s/edit/groups_management', ['user_id']); | |
89 | pyroutes.register('edit_user_groups_management_updates', '_admin/users/%(user_id)s/edit/edit_user_groups_management/updates', ['user_id']); |
|
89 | pyroutes.register('edit_user_groups_management_updates', '/_admin/users/%(user_id)s/edit/edit_user_groups_management/updates', ['user_id']); | |
90 | pyroutes.register('edit_user_audit_logs', '_admin/users/%(user_id)s/edit/audit', ['user_id']); |
|
90 | pyroutes.register('edit_user_audit_logs', '/_admin/users/%(user_id)s/edit/audit', ['user_id']); | |
91 | pyroutes.register('channelstream_connect', '/_admin/channelstream/connect', []); |
|
91 | pyroutes.register('channelstream_connect', '/_admin/channelstream/connect', []); | |
92 | pyroutes.register('channelstream_subscribe', '/_admin/channelstream/subscribe', []); |
|
92 | pyroutes.register('channelstream_subscribe', '/_admin/channelstream/subscribe', []); | |
93 | pyroutes.register('channelstream_proxy', '/_channelstream', []); |
|
93 | pyroutes.register('channelstream_proxy', '/_channelstream', []); | |
94 | pyroutes.register('login', '/_admin/login', []); |
|
94 | pyroutes.register('login', '/_admin/login', []); | |
95 | pyroutes.register('logout', '/_admin/logout', []); |
|
95 | pyroutes.register('logout', '/_admin/logout', []); | |
96 | pyroutes.register('register', '/_admin/register', []); |
|
96 | pyroutes.register('register', '/_admin/register', []); | |
97 | pyroutes.register('reset_password', '/_admin/password_reset', []); |
|
97 | pyroutes.register('reset_password', '/_admin/password_reset', []); | |
98 | pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []); |
|
98 | pyroutes.register('reset_password_confirmation', '/_admin/password_reset_confirmation', []); | |
99 | pyroutes.register('home', '/', []); |
|
99 | pyroutes.register('home', '/', []); | |
100 | pyroutes.register('user_autocomplete_data', '/_users', []); |
|
100 | pyroutes.register('user_autocomplete_data', '/_users', []); | |
101 | pyroutes.register('user_group_autocomplete_data', '/_user_groups', []); |
|
101 | pyroutes.register('user_group_autocomplete_data', '/_user_groups', []); | |
102 | pyroutes.register('repo_list_data', '/_repos', []); |
|
102 | pyroutes.register('repo_list_data', '/_repos', []); | |
103 | pyroutes.register('goto_switcher_data', '/_goto_data', []); |
|
103 | pyroutes.register('goto_switcher_data', '/_goto_data', []); | |
104 | pyroutes.register('repo_summary_explicit', '/%(repo_name)s/summary', ['repo_name']); |
|
104 | pyroutes.register('repo_summary_explicit', '/%(repo_name)s/summary', ['repo_name']); | |
105 | pyroutes.register('repo_summary_commits', '/%(repo_name)s/summary-commits', ['repo_name']); |
|
105 | pyroutes.register('repo_summary_commits', '/%(repo_name)s/summary-commits', ['repo_name']); | |
106 | pyroutes.register('repo_commit', '/%(repo_name)s/changeset/%(commit_id)s', ['repo_name', 'commit_id']); |
|
106 | pyroutes.register('repo_commit', '/%(repo_name)s/changeset/%(commit_id)s', ['repo_name', 'commit_id']); | |
107 | pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']); |
|
107 | pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']); | |
108 | pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']); |
|
108 | pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']); | |
109 | pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']); |
|
109 | pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']); | |
110 | pyroutes.register('tags_home', '/%(repo_name)s/tags', ['repo_name']); |
|
110 | pyroutes.register('tags_home', '/%(repo_name)s/tags', ['repo_name']); | |
111 | pyroutes.register('branches_home', '/%(repo_name)s/branches', ['repo_name']); |
|
111 | pyroutes.register('branches_home', '/%(repo_name)s/branches', ['repo_name']); | |
112 | pyroutes.register('bookmarks_home', '/%(repo_name)s/bookmarks', ['repo_name']); |
|
112 | pyroutes.register('bookmarks_home', '/%(repo_name)s/bookmarks', ['repo_name']); | |
113 | pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']); |
|
113 | pyroutes.register('pullrequest_show', '/%(repo_name)s/pull-request/%(pull_request_id)s', ['repo_name', 'pull_request_id']); | |
114 | pyroutes.register('pullrequest_show_all', '/%(repo_name)s/pull-request', ['repo_name']); |
|
114 | pyroutes.register('pullrequest_show_all', '/%(repo_name)s/pull-request', ['repo_name']); | |
115 | pyroutes.register('pullrequest_show_all_data', '/%(repo_name)s/pull-request-data', ['repo_name']); |
|
115 | pyroutes.register('pullrequest_show_all_data', '/%(repo_name)s/pull-request-data', ['repo_name']); | |
116 | pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']); |
|
116 | pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']); | |
117 | pyroutes.register('edit_repo_advanced', '/%(repo_name)s/settings/advanced', ['repo_name']); |
|
117 | pyroutes.register('edit_repo_advanced', '/%(repo_name)s/settings/advanced', ['repo_name']); | |
118 | pyroutes.register('edit_repo_advanced_delete', '/%(repo_name)s/settings/advanced/delete', ['repo_name']); |
|
118 | pyroutes.register('edit_repo_advanced_delete', '/%(repo_name)s/settings/advanced/delete', ['repo_name']); | |
119 | pyroutes.register('edit_repo_advanced_locking', '/%(repo_name)s/settings/advanced/locking', ['repo_name']); |
|
119 | pyroutes.register('edit_repo_advanced_locking', '/%(repo_name)s/settings/advanced/locking', ['repo_name']); | |
120 | pyroutes.register('edit_repo_advanced_journal', '/%(repo_name)s/settings/advanced/journal', ['repo_name']); |
|
120 | pyroutes.register('edit_repo_advanced_journal', '/%(repo_name)s/settings/advanced/journal', ['repo_name']); | |
121 | pyroutes.register('edit_repo_advanced_fork', '/%(repo_name)s/settings/advanced/fork', ['repo_name']); |
|
121 | pyroutes.register('edit_repo_advanced_fork', '/%(repo_name)s/settings/advanced/fork', ['repo_name']); | |
122 | pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']); |
|
122 | pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']); | |
123 | pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']); |
|
123 | pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']); | |
124 | pyroutes.register('repo_reviewers', '/%(repo_name)s/settings/review/rules', ['repo_name']); |
|
124 | pyroutes.register('repo_reviewers', '/%(repo_name)s/settings/review/rules', ['repo_name']); | |
125 | pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/settings/review/default-reviewers', ['repo_name']); |
|
125 | pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/settings/review/default-reviewers', ['repo_name']); | |
126 | pyroutes.register('repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']); |
|
126 | pyroutes.register('repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']); | |
127 | pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']); |
|
127 | pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']); | |
128 | pyroutes.register('strip', '/%(repo_name)s/settings/strip', ['repo_name']); |
|
128 | pyroutes.register('strip', '/%(repo_name)s/settings/strip', ['repo_name']); | |
129 | pyroutes.register('strip_check', '/%(repo_name)s/settings/strip_check', ['repo_name']); |
|
129 | pyroutes.register('strip_check', '/%(repo_name)s/settings/strip_check', ['repo_name']); | |
130 | pyroutes.register('strip_execute', '/%(repo_name)s/settings/strip_execute', ['repo_name']); |
|
130 | pyroutes.register('strip_execute', '/%(repo_name)s/settings/strip_execute', ['repo_name']); | |
131 | pyroutes.register('repo_summary', '/%(repo_name)s', ['repo_name']); |
|
131 | pyroutes.register('repo_summary', '/%(repo_name)s', ['repo_name']); | |
132 | pyroutes.register('repo_summary_slash', '/%(repo_name)s/', ['repo_name']); |
|
132 | pyroutes.register('repo_summary_slash', '/%(repo_name)s/', ['repo_name']); | |
133 | pyroutes.register('repo_group_home', '/%(repo_group_name)s', ['repo_group_name']); |
|
133 | pyroutes.register('repo_group_home', '/%(repo_group_name)s', ['repo_group_name']); | |
134 | pyroutes.register('repo_group_home_slash', '/%(repo_group_name)s/', ['repo_group_name']); |
|
134 | pyroutes.register('repo_group_home_slash', '/%(repo_group_name)s/', ['repo_group_name']); | |
135 | pyroutes.register('search', '/_admin/search', []); |
|
135 | pyroutes.register('search', '/_admin/search', []); | |
136 | pyroutes.register('search_repo', '/%(repo_name)s/search', ['repo_name']); |
|
136 | pyroutes.register('search_repo', '/%(repo_name)s/search', ['repo_name']); | |
137 | pyroutes.register('user_profile', '/_profiles/%(username)s', ['username']); |
|
137 | pyroutes.register('user_profile', '/_profiles/%(username)s', ['username']); | |
138 | pyroutes.register('my_account_profile', '/_admin/my_account/profile', []); |
|
138 | pyroutes.register('my_account_profile', '/_admin/my_account/profile', []); | |
139 | pyroutes.register('my_account_password', '/_admin/my_account/password', []); |
|
139 | pyroutes.register('my_account_password', '/_admin/my_account/password', []); | |
140 | pyroutes.register('my_account_password_update', '/_admin/my_account/password', []); |
|
140 | pyroutes.register('my_account_password_update', '/_admin/my_account/password', []); | |
141 | pyroutes.register('my_account_auth_tokens', '/_admin/my_account/auth_tokens', []); |
|
141 | pyroutes.register('my_account_auth_tokens', '/_admin/my_account/auth_tokens', []); | |
142 | pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []); |
|
142 | pyroutes.register('my_account_auth_tokens_add', '/_admin/my_account/auth_tokens/new', []); | |
143 | pyroutes.register('my_account_auth_tokens_delete', '/_admin/my_account/auth_tokens/delete', []); |
|
143 | pyroutes.register('my_account_auth_tokens_delete', '/_admin/my_account/auth_tokens/delete', []); | |
144 | pyroutes.register('my_account_emails', '/_admin/my_account/emails', []); |
|
144 | pyroutes.register('my_account_emails', '/_admin/my_account/emails', []); | |
145 | pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []); |
|
145 | pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []); | |
146 | pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []); |
|
146 | pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []); | |
147 | pyroutes.register('my_account_repos', '/_admin/my_account/repos', []); |
|
147 | pyroutes.register('my_account_repos', '/_admin/my_account/repos', []); | |
148 | pyroutes.register('my_account_watched', '/_admin/my_account/watched', []); |
|
148 | pyroutes.register('my_account_watched', '/_admin/my_account/watched', []); | |
149 | pyroutes.register('my_account_perms', '/_admin/my_account/perms', []); |
|
149 | pyroutes.register('my_account_perms', '/_admin/my_account/perms', []); | |
150 | pyroutes.register('my_account_notifications', '/_admin/my_account/notifications', []); |
|
150 | pyroutes.register('my_account_notifications', '/_admin/my_account/notifications', []); | |
151 | pyroutes.register('my_account_notifications_toggle_visibility', '/_admin/my_account/toggle_visibility', []); |
|
151 | pyroutes.register('my_account_notifications_toggle_visibility', '/_admin/my_account/toggle_visibility', []); | |
152 | pyroutes.register('my_account_notifications_test_channelstream', '/_admin/my_account/test_channelstream', []); |
|
152 | pyroutes.register('my_account_notifications_test_channelstream', '/_admin/my_account/test_channelstream', []); | |
153 | pyroutes.register('apiv2', '/_admin/api', []); |
|
153 | pyroutes.register('apiv2', '/_admin/api', []); | |
154 | } |
|
154 | } |
@@ -1,312 +1,315 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 | import io |
|
20 | import io | |
21 | import re |
|
21 | import re | |
22 | import datetime |
|
22 | import datetime | |
23 | import logging |
|
23 | import logging | |
24 | import pylons |
|
24 | import pylons | |
25 | import Queue |
|
25 | import Queue | |
26 | import subprocess32 |
|
26 | import subprocess32 | |
27 | import os |
|
27 | import os | |
28 |
|
28 | |||
29 | from pyramid.i18n import get_localizer |
|
29 | from pyramid.i18n import get_localizer | |
30 | from pyramid.threadlocal import get_current_request |
|
30 | from pyramid.threadlocal import get_current_request | |
31 | from pyramid.interfaces import IRoutesMapper |
|
31 | from pyramid.interfaces import IRoutesMapper | |
32 | from pyramid.settings import asbool |
|
32 | from pyramid.settings import asbool | |
33 | from pyramid.path import AssetResolver |
|
33 | from pyramid.path import AssetResolver | |
34 | from threading import Thread |
|
34 | from threading import Thread | |
35 |
|
35 | |||
36 | from rhodecode.translation import _ as tsf |
|
36 | from rhodecode.translation import _ as tsf | |
37 | from rhodecode.config.jsroutes import generate_jsroutes_content |
|
37 | from rhodecode.config.jsroutes import generate_jsroutes_content | |
38 |
|
38 | |||
39 | import rhodecode |
|
39 | import rhodecode | |
40 |
|
40 | |||
41 | from pylons.i18n.translation import _get_translator |
|
41 | from pylons.i18n.translation import _get_translator | |
42 | from pylons.util import ContextObj |
|
42 | from pylons.util import ContextObj | |
43 | from routes.util import URLGenerator |
|
43 | from routes.util import URLGenerator | |
44 |
|
44 | |||
45 | from rhodecode.lib.base import attach_context_attributes, get_auth_user |
|
45 | from rhodecode.lib.base import attach_context_attributes, get_auth_user | |
46 |
|
46 | |||
47 | log = logging.getLogger(__name__) |
|
47 | log = logging.getLogger(__name__) | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | def add_renderer_globals(event): |
|
50 | def add_renderer_globals(event): | |
51 | # Put pylons stuff into the context. This will be removed as soon as |
|
51 | # Put pylons stuff into the context. This will be removed as soon as | |
52 | # migration to pyramid is finished. |
|
52 | # migration to pyramid is finished. | |
53 | conf = pylons.config._current_obj() |
|
53 | conf = pylons.config._current_obj() | |
54 | event['h'] = conf.get('pylons.h') |
|
54 | event['h'] = conf.get('pylons.h') | |
55 | event['c'] = pylons.tmpl_context |
|
55 | event['c'] = pylons.tmpl_context | |
56 | event['url'] = pylons.url |
|
56 | event['url'] = pylons.url | |
57 |
|
57 | |||
58 | # TODO: When executed in pyramid view context the request is not available |
|
58 | # TODO: When executed in pyramid view context the request is not available | |
59 | # in the event. Find a better solution to get the request. |
|
59 | # in the event. Find a better solution to get the request. | |
60 | request = event['request'] or get_current_request() |
|
60 | request = event['request'] or get_current_request() | |
61 |
|
61 | |||
62 | # Add Pyramid translation as '_' to context |
|
62 | # Add Pyramid translation as '_' to context | |
63 | event['_'] = request.translate |
|
63 | event['_'] = request.translate | |
64 | event['_ungettext'] = request.plularize |
|
64 | event['_ungettext'] = request.plularize | |
65 |
|
65 | |||
66 |
|
66 | |||
67 | def add_localizer(event): |
|
67 | def add_localizer(event): | |
68 | request = event.request |
|
68 | request = event.request | |
69 | localizer = get_localizer(request) |
|
69 | localizer = get_localizer(request) | |
70 |
|
70 | |||
71 | def auto_translate(*args, **kwargs): |
|
71 | def auto_translate(*args, **kwargs): | |
72 | return localizer.translate(tsf(*args, **kwargs)) |
|
72 | return localizer.translate(tsf(*args, **kwargs)) | |
73 |
|
73 | |||
74 | request.localizer = localizer |
|
74 | request.localizer = localizer | |
75 | request.translate = auto_translate |
|
75 | request.translate = auto_translate | |
76 | request.plularize = localizer.pluralize |
|
76 | request.plularize = localizer.pluralize | |
77 |
|
77 | |||
78 |
|
78 | |||
79 | def set_user_lang(event): |
|
79 | def set_user_lang(event): | |
80 | request = event.request |
|
80 | request = event.request | |
81 | cur_user = getattr(request, 'user', None) |
|
81 | cur_user = getattr(request, 'user', None) | |
82 |
|
82 | |||
83 | if cur_user: |
|
83 | if cur_user: | |
84 | user_lang = cur_user.get_instance().user_data.get('language') |
|
84 | user_lang = cur_user.get_instance().user_data.get('language') | |
85 | if user_lang: |
|
85 | if user_lang: | |
86 | log.debug('lang: setting current user:%s language to: %s', cur_user, user_lang) |
|
86 | log.debug('lang: setting current user:%s language to: %s', cur_user, user_lang) | |
87 | event.request._LOCALE_ = user_lang |
|
87 | event.request._LOCALE_ = user_lang | |
88 |
|
88 | |||
89 |
|
89 | |||
90 | def add_pylons_context(event): |
|
90 | def add_pylons_context(event): | |
91 | request = event.request |
|
91 | request = event.request | |
92 |
|
92 | |||
93 | config = rhodecode.CONFIG |
|
93 | config = rhodecode.CONFIG | |
94 | environ = request.environ |
|
94 | environ = request.environ | |
95 | session = request.session |
|
95 | session = request.session | |
96 |
|
96 | |||
97 | if hasattr(request, 'vcs_call'): |
|
97 | if hasattr(request, 'vcs_call'): | |
98 | # skip vcs calls |
|
98 | # skip vcs calls | |
99 | return |
|
99 | return | |
100 |
|
100 | |||
101 | # Setup pylons globals. |
|
101 | # Setup pylons globals. | |
102 | pylons.config._push_object(config) |
|
102 | pylons.config._push_object(config) | |
103 | pylons.request._push_object(request) |
|
103 | pylons.request._push_object(request) | |
104 | pylons.session._push_object(session) |
|
104 | pylons.session._push_object(session) | |
105 | pylons.translator._push_object(_get_translator(config.get('lang'))) |
|
105 | pylons.translator._push_object(_get_translator(config.get('lang'))) | |
106 |
|
106 | |||
107 | pylons.url._push_object(URLGenerator(config['routes.map'], environ)) |
|
107 | pylons.url._push_object(URLGenerator(config['routes.map'], environ)) | |
108 | session_key = ( |
|
108 | session_key = ( | |
109 | config['pylons.environ_config'].get('session', 'beaker.session')) |
|
109 | config['pylons.environ_config'].get('session', 'beaker.session')) | |
110 | environ[session_key] = session |
|
110 | environ[session_key] = session | |
111 |
|
111 | |||
112 | if hasattr(request, 'rpc_method'): |
|
112 | if hasattr(request, 'rpc_method'): | |
113 | # skip api calls |
|
113 | # skip api calls | |
114 | return |
|
114 | return | |
115 |
|
115 | |||
116 | # Get the rhodecode auth user object and make it available. |
|
116 | # Get the rhodecode auth user object and make it available. | |
117 | auth_user = get_auth_user(environ) |
|
117 | auth_user = get_auth_user(environ) | |
118 | request.user = auth_user |
|
118 | request.user = auth_user | |
119 | environ['rc_auth_user'] = auth_user |
|
119 | environ['rc_auth_user'] = auth_user | |
120 |
|
120 | |||
121 | # Setup the pylons context object ('c') |
|
121 | # Setup the pylons context object ('c') | |
122 | context = ContextObj() |
|
122 | context = ContextObj() | |
123 | context.rhodecode_user = auth_user |
|
123 | context.rhodecode_user = auth_user | |
124 | attach_context_attributes(context, request, request.user.user_id) |
|
124 | attach_context_attributes(context, request, request.user.user_id) | |
125 | pylons.tmpl_context._push_object(context) |
|
125 | pylons.tmpl_context._push_object(context) | |
126 |
|
126 | |||
127 |
|
127 | |||
128 | def scan_repositories_if_enabled(event): |
|
128 | def scan_repositories_if_enabled(event): | |
129 | """ |
|
129 | """ | |
130 | This is subscribed to the `pyramid.events.ApplicationCreated` event. It |
|
130 | This is subscribed to the `pyramid.events.ApplicationCreated` event. It | |
131 | does a repository scan if enabled in the settings. |
|
131 | does a repository scan if enabled in the settings. | |
132 | """ |
|
132 | """ | |
133 | settings = event.app.registry.settings |
|
133 | settings = event.app.registry.settings | |
134 | vcs_server_enabled = settings['vcs.server.enable'] |
|
134 | vcs_server_enabled = settings['vcs.server.enable'] | |
135 | import_on_startup = settings['startup.import_repos'] |
|
135 | import_on_startup = settings['startup.import_repos'] | |
136 | if vcs_server_enabled and import_on_startup: |
|
136 | if vcs_server_enabled and import_on_startup: | |
137 | from rhodecode.model.scm import ScmModel |
|
137 | from rhodecode.model.scm import ScmModel | |
138 | from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_base_path |
|
138 | from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_base_path | |
139 | repositories = ScmModel().repo_scan(get_rhodecode_base_path()) |
|
139 | repositories = ScmModel().repo_scan(get_rhodecode_base_path()) | |
140 | repo2db_mapper(repositories, remove_obsolete=False) |
|
140 | repo2db_mapper(repositories, remove_obsolete=False) | |
141 |
|
141 | |||
142 |
|
142 | |||
143 | def write_metadata_if_needed(event): |
|
143 | def write_metadata_if_needed(event): | |
144 | """ |
|
144 | """ | |
145 | Writes upgrade metadata |
|
145 | Writes upgrade metadata | |
146 | """ |
|
146 | """ | |
147 | import rhodecode |
|
147 | import rhodecode | |
148 | from rhodecode.lib import system_info |
|
148 | from rhodecode.lib import system_info | |
149 | from rhodecode.lib import ext_json |
|
149 | from rhodecode.lib import ext_json | |
150 |
|
150 | |||
151 | def write(): |
|
151 | def write(): | |
152 | fname = '.rcmetadata.json' |
|
152 | fname = '.rcmetadata.json' | |
153 | ini_loc = os.path.dirname(rhodecode.CONFIG.get('__file__')) |
|
153 | ini_loc = os.path.dirname(rhodecode.CONFIG.get('__file__')) | |
154 | metadata_destination = os.path.join(ini_loc, fname) |
|
154 | metadata_destination = os.path.join(ini_loc, fname) | |
155 |
|
155 | |||
156 | configuration = system_info.SysInfo( |
|
156 | configuration = system_info.SysInfo( | |
157 | system_info.rhodecode_config)()['value'] |
|
157 | system_info.rhodecode_config)()['value'] | |
158 | license_token = configuration['config']['license_token'] |
|
158 | license_token = configuration['config']['license_token'] | |
159 | dbinfo = system_info.SysInfo(system_info.database_info)()['value'] |
|
159 | dbinfo = system_info.SysInfo(system_info.database_info)()['value'] | |
160 | del dbinfo['url'] |
|
160 | del dbinfo['url'] | |
161 | metadata = dict( |
|
161 | metadata = dict( | |
162 | desc='upgrade metadata info', |
|
162 | desc='upgrade metadata info', | |
163 | license_token=license_token, |
|
163 | license_token=license_token, | |
164 | created_on=datetime.datetime.utcnow().isoformat(), |
|
164 | created_on=datetime.datetime.utcnow().isoformat(), | |
165 | usage=system_info.SysInfo(system_info.usage_info)()['value'], |
|
165 | usage=system_info.SysInfo(system_info.usage_info)()['value'], | |
166 | platform=system_info.SysInfo(system_info.platform_type)()['value'], |
|
166 | platform=system_info.SysInfo(system_info.platform_type)()['value'], | |
167 | database=dbinfo, |
|
167 | database=dbinfo, | |
168 | cpu=system_info.SysInfo(system_info.cpu)()['value'], |
|
168 | cpu=system_info.SysInfo(system_info.cpu)()['value'], | |
169 | memory=system_info.SysInfo(system_info.memory)()['value'], |
|
169 | memory=system_info.SysInfo(system_info.memory)()['value'], | |
170 | ) |
|
170 | ) | |
171 |
|
171 | |||
172 | with open(metadata_destination, 'wb') as f: |
|
172 | with open(metadata_destination, 'wb') as f: | |
173 | f.write(ext_json.json.dumps(metadata)) |
|
173 | f.write(ext_json.json.dumps(metadata)) | |
174 |
|
174 | |||
175 | settings = event.app.registry.settings |
|
175 | settings = event.app.registry.settings | |
176 | if settings.get('metadata.skip'): |
|
176 | if settings.get('metadata.skip'): | |
177 | return |
|
177 | return | |
178 |
|
178 | |||
179 | try: |
|
179 | try: | |
180 | write() |
|
180 | write() | |
181 | except Exception: |
|
181 | except Exception: | |
182 | pass |
|
182 | pass | |
183 |
|
183 | |||
184 |
|
184 | |||
185 | def write_js_routes_if_enabled(event): |
|
185 | def write_js_routes_if_enabled(event): | |
186 | registry = event.app.registry |
|
186 | registry = event.app.registry | |
187 |
|
187 | |||
188 | mapper = registry.queryUtility(IRoutesMapper) |
|
188 | mapper = registry.queryUtility(IRoutesMapper) | |
189 | _argument_prog = re.compile('\{(.*?)\}|:\((.*)\)') |
|
189 | _argument_prog = re.compile('\{(.*?)\}|:\((.*)\)') | |
190 |
|
190 | |||
191 | def _extract_route_information(route): |
|
191 | def _extract_route_information(route): | |
192 | """ |
|
192 | """ | |
193 | Convert a route into tuple(name, path, args), eg: |
|
193 | Convert a route into tuple(name, path, args), eg: | |
194 | ('show_user', '/profile/%(username)s', ['username']) |
|
194 | ('show_user', '/profile/%(username)s', ['username']) | |
195 | """ |
|
195 | """ | |
196 |
|
196 | |||
197 | routepath = route.pattern |
|
197 | routepath = route.pattern | |
198 | pattern = route.pattern |
|
198 | pattern = route.pattern | |
199 |
|
199 | |||
200 | def replace(matchobj): |
|
200 | def replace(matchobj): | |
201 | if matchobj.group(1): |
|
201 | if matchobj.group(1): | |
202 | return "%%(%s)s" % matchobj.group(1).split(':')[0] |
|
202 | return "%%(%s)s" % matchobj.group(1).split(':')[0] | |
203 | else: |
|
203 | else: | |
204 | return "%%(%s)s" % matchobj.group(2) |
|
204 | return "%%(%s)s" % matchobj.group(2) | |
205 |
|
205 | |||
206 | routepath = _argument_prog.sub(replace, routepath) |
|
206 | routepath = _argument_prog.sub(replace, routepath) | |
207 |
|
207 | |||
|
208 | if not routepath.startswith('/'): | |||
|
209 | routepath = '/'+routepath | |||
|
210 | ||||
208 | return ( |
|
211 | return ( | |
209 | route.name, |
|
212 | route.name, | |
210 | routepath, |
|
213 | routepath, | |
211 | [(arg[0].split(':')[0] if arg[0] != '' else arg[1]) |
|
214 | [(arg[0].split(':')[0] if arg[0] != '' else arg[1]) | |
212 | for arg in _argument_prog.findall(pattern)] |
|
215 | for arg in _argument_prog.findall(pattern)] | |
213 | ) |
|
216 | ) | |
214 |
|
217 | |||
215 | def get_routes(): |
|
218 | def get_routes(): | |
216 | # pylons routes |
|
219 | # pylons routes | |
217 | for route in rhodecode.CONFIG['routes.map'].jsroutes(): |
|
220 | for route in rhodecode.CONFIG['routes.map'].jsroutes(): | |
218 | yield route |
|
221 | yield route | |
219 |
|
222 | |||
220 | # pyramid routes |
|
223 | # pyramid routes | |
221 | for route in mapper.get_routes(): |
|
224 | for route in mapper.get_routes(): | |
222 | if not route.name.startswith('__'): |
|
225 | if not route.name.startswith('__'): | |
223 | yield _extract_route_information(route) |
|
226 | yield _extract_route_information(route) | |
224 |
|
227 | |||
225 | if asbool(registry.settings.get('generate_js_files', 'false')): |
|
228 | if asbool(registry.settings.get('generate_js_files', 'false')): | |
226 | static_path = AssetResolver().resolve('rhodecode:public').abspath() |
|
229 | static_path = AssetResolver().resolve('rhodecode:public').abspath() | |
227 | jsroutes = get_routes() |
|
230 | jsroutes = get_routes() | |
228 | jsroutes_file_content = generate_jsroutes_content(jsroutes) |
|
231 | jsroutes_file_content = generate_jsroutes_content(jsroutes) | |
229 | jsroutes_file_path = os.path.join( |
|
232 | jsroutes_file_path = os.path.join( | |
230 | static_path, 'js', 'rhodecode', 'routes.js') |
|
233 | static_path, 'js', 'rhodecode', 'routes.js') | |
231 |
|
234 | |||
232 | with io.open(jsroutes_file_path, 'w', encoding='utf-8') as f: |
|
235 | with io.open(jsroutes_file_path, 'w', encoding='utf-8') as f: | |
233 | f.write(jsroutes_file_content) |
|
236 | f.write(jsroutes_file_content) | |
234 |
|
237 | |||
235 |
|
238 | |||
236 | class Subscriber(object): |
|
239 | class Subscriber(object): | |
237 | """ |
|
240 | """ | |
238 | Base class for subscribers to the pyramid event system. |
|
241 | Base class for subscribers to the pyramid event system. | |
239 | """ |
|
242 | """ | |
240 | def __call__(self, event): |
|
243 | def __call__(self, event): | |
241 | self.run(event) |
|
244 | self.run(event) | |
242 |
|
245 | |||
243 | def run(self, event): |
|
246 | def run(self, event): | |
244 | raise NotImplementedError('Subclass has to implement this.') |
|
247 | raise NotImplementedError('Subclass has to implement this.') | |
245 |
|
248 | |||
246 |
|
249 | |||
247 | class AsyncSubscriber(Subscriber): |
|
250 | class AsyncSubscriber(Subscriber): | |
248 | """ |
|
251 | """ | |
249 | Subscriber that handles the execution of events in a separate task to not |
|
252 | Subscriber that handles the execution of events in a separate task to not | |
250 | block the execution of the code which triggers the event. It puts the |
|
253 | block the execution of the code which triggers the event. It puts the | |
251 | received events into a queue from which the worker process takes them in |
|
254 | received events into a queue from which the worker process takes them in | |
252 | order. |
|
255 | order. | |
253 | """ |
|
256 | """ | |
254 | def __init__(self): |
|
257 | def __init__(self): | |
255 | self._stop = False |
|
258 | self._stop = False | |
256 | self._eventq = Queue.Queue() |
|
259 | self._eventq = Queue.Queue() | |
257 | self._worker = self.create_worker() |
|
260 | self._worker = self.create_worker() | |
258 | self._worker.start() |
|
261 | self._worker.start() | |
259 |
|
262 | |||
260 | def __call__(self, event): |
|
263 | def __call__(self, event): | |
261 | self._eventq.put(event) |
|
264 | self._eventq.put(event) | |
262 |
|
265 | |||
263 | def create_worker(self): |
|
266 | def create_worker(self): | |
264 | worker = Thread(target=self.do_work) |
|
267 | worker = Thread(target=self.do_work) | |
265 | worker.daemon = True |
|
268 | worker.daemon = True | |
266 | return worker |
|
269 | return worker | |
267 |
|
270 | |||
268 | def stop_worker(self): |
|
271 | def stop_worker(self): | |
269 | self._stop = False |
|
272 | self._stop = False | |
270 | self._eventq.put(None) |
|
273 | self._eventq.put(None) | |
271 | self._worker.join() |
|
274 | self._worker.join() | |
272 |
|
275 | |||
273 | def do_work(self): |
|
276 | def do_work(self): | |
274 | while not self._stop: |
|
277 | while not self._stop: | |
275 | event = self._eventq.get() |
|
278 | event = self._eventq.get() | |
276 | if event is not None: |
|
279 | if event is not None: | |
277 | self.run(event) |
|
280 | self.run(event) | |
278 |
|
281 | |||
279 |
|
282 | |||
280 | class AsyncSubprocessSubscriber(AsyncSubscriber): |
|
283 | class AsyncSubprocessSubscriber(AsyncSubscriber): | |
281 | """ |
|
284 | """ | |
282 | Subscriber that uses the subprocess32 module to execute a command if an |
|
285 | Subscriber that uses the subprocess32 module to execute a command if an | |
283 | event is received. Events are handled asynchronously. |
|
286 | event is received. Events are handled asynchronously. | |
284 | """ |
|
287 | """ | |
285 |
|
288 | |||
286 | def __init__(self, cmd, timeout=None): |
|
289 | def __init__(self, cmd, timeout=None): | |
287 | super(AsyncSubprocessSubscriber, self).__init__() |
|
290 | super(AsyncSubprocessSubscriber, self).__init__() | |
288 | self._cmd = cmd |
|
291 | self._cmd = cmd | |
289 | self._timeout = timeout |
|
292 | self._timeout = timeout | |
290 |
|
293 | |||
291 | def run(self, event): |
|
294 | def run(self, event): | |
292 | cmd = self._cmd |
|
295 | cmd = self._cmd | |
293 | timeout = self._timeout |
|
296 | timeout = self._timeout | |
294 | log.debug('Executing command %s.', cmd) |
|
297 | log.debug('Executing command %s.', cmd) | |
295 |
|
298 | |||
296 | try: |
|
299 | try: | |
297 | output = subprocess32.check_output( |
|
300 | output = subprocess32.check_output( | |
298 | cmd, timeout=timeout, stderr=subprocess32.STDOUT) |
|
301 | cmd, timeout=timeout, stderr=subprocess32.STDOUT) | |
299 | log.debug('Command finished %s', cmd) |
|
302 | log.debug('Command finished %s', cmd) | |
300 | if output: |
|
303 | if output: | |
301 | log.debug('Command output: %s', output) |
|
304 | log.debug('Command output: %s', output) | |
302 | except subprocess32.TimeoutExpired as e: |
|
305 | except subprocess32.TimeoutExpired as e: | |
303 | log.exception('Timeout while executing command.') |
|
306 | log.exception('Timeout while executing command.') | |
304 | if e.output: |
|
307 | if e.output: | |
305 | log.error('Command output: %s', e.output) |
|
308 | log.error('Command output: %s', e.output) | |
306 | except subprocess32.CalledProcessError as e: |
|
309 | except subprocess32.CalledProcessError as e: | |
307 | log.exception('Error while executing command.') |
|
310 | log.exception('Error while executing command.') | |
308 | if e.output: |
|
311 | if e.output: | |
309 | log.error('Command output: %s', e.output) |
|
312 | log.error('Command output: %s', e.output) | |
310 | except: |
|
313 | except: | |
311 | log.exception( |
|
314 | log.exception( | |
312 | 'Exception while executing command %s.', cmd) |
|
315 | 'Exception while executing command %s.', cmd) |
General Comments 0
You need to be logged in to leave comments.
Login now