##// END OF EJS Templates
pep8ify
marcink -
r1211:a7e7c0fa beta
parent child Browse files
Show More
@@ -12,15 +12,14 b' from rhodecode.lib.utils import check_re'
12
12
13 def make_map(config):
13 def make_map(config):
14 """Create, configure and return the routes Mapper"""
14 """Create, configure and return the routes Mapper"""
15 routes_map = Mapper(directory=config['pylons.paths']['controllers'],
15 rmap = Mapper(directory=config['pylons.paths']['controllers'],
16 always_scan=config['debug'])
16 always_scan=config['debug'])
17 routes_map.minimization = False
17 rmap.minimization = False
18 routes_map.explicit = False
18 rmap.explicit = False
19
19
20 def check_repo(environ, match_dict):
20 def check_repo(environ, match_dict):
21 """
21 """
22 check for valid repository for proper 404 handling
22 check for valid repository for proper 404 handling
23
24 :param environ:
23 :param environ:
25 :param match_dict:
24 :param match_dict:
26 """
25 """
@@ -29,21 +28,22 b' def make_map(config):'
29
28
30 # The ErrorController route (handles 404/500 error pages); it should
29 # The ErrorController route (handles 404/500 error pages); it should
31 # likely stay at the top, ensuring it can always be resolved
30 # likely stay at the top, ensuring it can always be resolved
32 routes_map.connect('/error/{action}', controller='error')
31 rmap.connect('/error/{action}', controller='error')
33 routes_map.connect('/error/{action}/{id}', controller='error')
32 rmap.connect('/error/{action}/{id}', controller='error')
34
33
35 #==========================================================================
34 #==========================================================================
36 # CUSTOM ROUTES HERE
35 # CUSTOM ROUTES HERE
37 #==========================================================================
36 #==========================================================================
38
37
39 #MAIN PAGE
38 #MAIN PAGE
40 routes_map.connect('home', '/', controller='home', action='index')
39 rmap.connect('home', '/', controller='home', action='index')
41 routes_map.connect('repo_switcher', '/repos', controller='home', action='repo_switcher')
40 rmap.connect('bugtracker',
42 routes_map.connect('bugtracker', "http://bitbucket.org/marcinkuzminski/rhodecode/issues", _static=True)
41 "http://bitbucket.org/marcinkuzminski/rhodecode/issues",
43 routes_map.connect('rhodecode_official', "http://rhodecode.org", _static=True)
42 _static=True)
43 rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True)
44
44
45 #ADMIN REPOSITORY REST ROUTES
45 #ADMIN REPOSITORY REST ROUTES
46 with routes_map.submapper(path_prefix='/_admin', controller='admin/repos') as m:
46 with rmap.submapper(path_prefix='/_admin', controller='admin/repos') as m:
47 m.connect("repos", "/repos",
47 m.connect("repos", "/repos",
48 action="create", conditions=dict(method=["POST"]))
48 action="create", conditions=dict(method=["POST"]))
49 m.connect("repos", "/repos",
49 m.connect("repos", "/repos",
@@ -78,9 +78,10 b' def make_map(config):'
78 action="delete_perm_user", conditions=dict(method=["DELETE"],
78 action="delete_perm_user", conditions=dict(method=["DELETE"],
79 function=check_repo))
79 function=check_repo))
80 #ajax delete repo perm users_group
80 #ajax delete repo perm users_group
81 m.connect('delete_repo_users_group', "/repos_delete_users_group/{repo_name:.*}",
81 m.connect('delete_repo_users_group',
82 action="delete_perm_users_group", conditions=dict(method=["DELETE"],
82 "/repos_delete_users_group/{repo_name:.*}",
83 function=check_repo))
83 action="delete_perm_users_group",
84 conditions=dict(method=["DELETE"], function=check_repo))
84
85
85 #settings actions
86 #settings actions
86 m.connect('repo_stats', "/repos_stats/{repo_name:.*}",
87 m.connect('repo_stats', "/repos_stats/{repo_name:.*}",
@@ -89,153 +90,194 b' def make_map(config):'
89 m.connect('repo_cache', "/repos_cache/{repo_name:.*}",
90 m.connect('repo_cache', "/repos_cache/{repo_name:.*}",
90 action="repo_cache", conditions=dict(method=["DELETE"],
91 action="repo_cache", conditions=dict(method=["DELETE"],
91 function=check_repo))
92 function=check_repo))
92 m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*}",
93 m.connect('repo_public_journal',
93 action="repo_public_journal", conditions=dict(method=["PUT"],
94 "/repos_public_journal/{repo_name:.*}",
94 function=check_repo))
95 action="repo_public_journal", conditions=dict(method=["PUT"],
96 function=check_repo))
95 m.connect('repo_pull', "/repo_pull/{repo_name:.*}",
97 m.connect('repo_pull', "/repo_pull/{repo_name:.*}",
96 action="repo_pull", conditions=dict(method=["PUT"],
98 action="repo_pull", conditions=dict(method=["PUT"],
97 function=check_repo))
99 function=check_repo))
98
100
99 #ADMIN REPOS GROUP REST ROUTES
101 #ADMIN REPOS GROUP REST ROUTES
100 routes_map.resource('repos_group', 'repos_groups', controller='admin/repos_groups', path_prefix='/_admin')
102 rmap.resource('repos_group', 'repos_groups',
103 controller='admin/repos_groups', path_prefix='/_admin')
101
104
102 #ADMIN USER REST ROUTES
105 #ADMIN USER REST ROUTES
103 routes_map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
106 rmap.resource('user', 'users', controller='admin/users',
107 path_prefix='/_admin')
104
108
105 #ADMIN USERS REST ROUTES
109 #ADMIN USERS REST ROUTES
106 routes_map.resource('users_group', 'users_groups', controller='admin/users_groups', path_prefix='/_admin')
110 rmap.resource('users_group', 'users_groups',
111 controller='admin/users_groups', path_prefix='/_admin')
107
112
108 #ADMIN GROUP REST ROUTES
113 #ADMIN GROUP REST ROUTES
109 routes_map.resource('group', 'groups', controller='admin/groups', path_prefix='/_admin')
114 rmap.resource('group', 'groups', controller='admin/groups',
115 path_prefix='/_admin')
110
116
111 #ADMIN PERMISSIONS REST ROUTES
117 #ADMIN PERMISSIONS REST ROUTES
112 routes_map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin')
118 rmap.resource('permission', 'permissions',
119 controller='admin/permissions', path_prefix='/_admin')
113
120
114 ##ADMIN LDAP SETTINGS
121 ##ADMIN LDAP SETTINGS
115 routes_map.connect('ldap_settings', '/_admin/ldap', controller='admin/ldap_settings',
122 rmap.connect('ldap_settings', '/_admin/ldap',
116 action='ldap_settings', conditions=dict(method=["POST"]))
123 controller='admin/ldap_settings', action='ldap_settings',
117 routes_map.connect('ldap_home', '/_admin/ldap', controller='admin/ldap_settings')
124 conditions=dict(method=["POST"]))
118
125 rmap.connect('ldap_home', '/_admin/ldap',
126 controller='admin/ldap_settings')
119
127
120 #ADMIN SETTINGS REST ROUTES
128 #ADMIN SETTINGS REST ROUTES
121 with routes_map.submapper(path_prefix='/_admin', controller='admin/settings') as m:
129 with rmap.submapper(path_prefix='/_admin',
130 controller='admin/settings') as m:
122 m.connect("admin_settings", "/settings",
131 m.connect("admin_settings", "/settings",
123 action="create", conditions=dict(method=["POST"]))
132 action="create", conditions=dict(method=["POST"]))
124 m.connect("admin_settings", "/settings",
133 m.connect("admin_settings", "/settings",
125 action="index", conditions=dict(method=["GET"]))
134 action="index", conditions=dict(method=["GET"]))
126 m.connect("formatted_admin_settings", "/settings.{format}",
135 m.connect("formatted_admin_settings", "/settings.{format}",
127 action="index", conditions=dict(method=["GET"]))
136 action="index", conditions=dict(method=["GET"]))
128 m.connect("admin_new_setting", "/settings/new",
137 m.connect("admin_new_setting", "/settings/new",
129 action="new", conditions=dict(method=["GET"]))
138 action="new", conditions=dict(method=["GET"]))
130 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
139 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
131 action="new", conditions=dict(method=["GET"]))
140 action="new", conditions=dict(method=["GET"]))
132 m.connect("/settings/{setting_id}",
141 m.connect("/settings/{setting_id}",
133 action="update", conditions=dict(method=["PUT"]))
142 action="update", conditions=dict(method=["PUT"]))
134 m.connect("/settings/{setting_id}",
143 m.connect("/settings/{setting_id}",
135 action="delete", conditions=dict(method=["DELETE"]))
144 action="delete", conditions=dict(method=["DELETE"]))
136 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
145 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
137 action="edit", conditions=dict(method=["GET"]))
146 action="edit", conditions=dict(method=["GET"]))
138 m.connect("formatted_admin_edit_setting", "/settings/{setting_id}.{format}/edit",
147 m.connect("formatted_admin_edit_setting",
139 action="edit", conditions=dict(method=["GET"]))
148 "/settings/{setting_id}.{format}/edit",
149 action="edit", conditions=dict(method=["GET"]))
140 m.connect("admin_setting", "/settings/{setting_id}",
150 m.connect("admin_setting", "/settings/{setting_id}",
141 action="show", conditions=dict(method=["GET"]))
151 action="show", conditions=dict(method=["GET"]))
142 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
152 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
143 action="show", conditions=dict(method=["GET"]))
153 action="show", conditions=dict(method=["GET"]))
144 m.connect("admin_settings_my_account", "/my_account",
154 m.connect("admin_settings_my_account", "/my_account",
145 action="my_account", conditions=dict(method=["GET"]))
155 action="my_account", conditions=dict(method=["GET"]))
146 m.connect("admin_settings_my_account_update", "/my_account_update",
156 m.connect("admin_settings_my_account_update", "/my_account_update",
147 action="my_account_update", conditions=dict(method=["PUT"]))
157 action="my_account_update", conditions=dict(method=["PUT"]))
148 m.connect("admin_settings_create_repository", "/create_repository",
158 m.connect("admin_settings_create_repository", "/create_repository",
149 action="create_repository", conditions=dict(method=["GET"]))
159 action="create_repository", conditions=dict(method=["GET"]))
150
160
151 #ADMIN MAIN PAGES
161 #ADMIN MAIN PAGES
152 with routes_map.submapper(path_prefix='/_admin', controller='admin/admin') as m:
162 with rmap.submapper(path_prefix='/_admin', controller='admin/admin') as m:
153 m.connect('admin_home', '', action='index')#main page
163 m.connect('admin_home', '', action='index')
154 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
164 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
155 action='add_repo')
165 action='add_repo')
156
166
167 #USER JOURNAL
168 rmap.connect('journal', '/_admin/journal', controller='journal')
157
169
158 #USER JOURNAL
170 rmap.connect('public_journal', '/_admin/public_journal',
159 routes_map.connect('journal', '/_admin/journal', controller='journal')
171 controller='journal', action="public_journal")
160 routes_map.connect('public_journal', '/_admin/public_journal', controller='journal', action="public_journal")
172
161 routes_map.connect('public_journal_rss', '/_admin/public_journal_rss', controller='journal', action="public_journal_rss")
173 rmap.connect('public_journal_rss', '/_admin/public_journal_rss',
162 routes_map.connect('public_journal_atom', '/_admin/public_journal_atom', controller='journal', action="public_journal_atom")
174 controller='journal', action="public_journal_rss")
163
175
164 routes_map.connect('toggle_following', '/_admin/toggle_following', controller='journal',
176 rmap.connect('public_journal_atom', '/_admin/public_journal_atom',
165 action='toggle_following', conditions=dict(method=["POST"]))
177 controller='journal', action="public_journal_atom")
166
178
179 rmap.connect('toggle_following', '/_admin/toggle_following',
180 controller='journal', action='toggle_following',
181 conditions=dict(method=["POST"]))
167
182
168 #SEARCH
183 #SEARCH
169 routes_map.connect('search', '/_admin/search', controller='search')
184 rmap.connect('search', '/_admin/search', controller='search',)
170 routes_map.connect('search_repo', '/_admin/search/{search_repo:.*}', controller='search')
185 rmap.connect('search_repo', '/_admin/search/{search_repo:.*}',
186 controller='search')
171
187
172 #LOGIN/LOGOUT/REGISTER/SIGN IN
188 #LOGIN/LOGOUT/REGISTER/SIGN IN
173 routes_map.connect('login_home', '/_admin/login', controller='login')
189 rmap.connect('login_home', '/_admin/login', controller='login')
174 routes_map.connect('logout_home', '/_admin/logout', controller='login', action='logout')
190 rmap.connect('logout_home', '/_admin/logout', controller='login',
175 routes_map.connect('register', '/_admin/register', controller='login', action='register')
191 action='logout')
176 routes_map.connect('reset_password', '/_admin/password_reset', controller='login', action='password_reset')
192
193 rmap.connect('register', '/_admin/register', controller='login',
194 action='register')
195
196 rmap.connect('reset_password', '/_admin/password_reset',
197 controller='login', action='password_reset')
177
198
178 #FEEDS
199 #FEEDS
179 routes_map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
200 rmap.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
180 controller='feed', action='rss',
201 controller='feed', action='rss',
181 conditions=dict(function=check_repo))
202 conditions=dict(function=check_repo))
182 routes_map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
203
204 rmap.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
183 controller='feed', action='atom',
205 controller='feed', action='atom',
184 conditions=dict(function=check_repo))
206 conditions=dict(function=check_repo))
185
207
186
187 #REPOSITORY ROUTES
208 #REPOSITORY ROUTES
188 routes_map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
209 rmap.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
189 controller='changeset', revision='tip',
210 controller='changeset', revision='tip',
190 conditions=dict(function=check_repo))
211 conditions=dict(function=check_repo))
191 routes_map.connect('raw_changeset_home', '/{repo_name:.*}/raw-changeset/{revision}',
212
192 controller='changeset', action='raw_changeset', revision='tip',
213 rmap.connect('raw_changeset_home',
193 conditions=dict(function=check_repo))
214 '/{repo_name:.*}/raw-changeset/{revision}',
194 routes_map.connect('summary_home', '/{repo_name:.*}',
215 controller='changeset', action='raw_changeset',
216 revision='tip', conditions=dict(function=check_repo))
217
218 rmap.connect('summary_home', '/{repo_name:.*}',
195 controller='summary', conditions=dict(function=check_repo))
219 controller='summary', conditions=dict(function=check_repo))
196 routes_map.connect('summary_home', '/{repo_name:.*}/summary',
220
221 rmap.connect('summary_home', '/{repo_name:.*}/summary',
197 controller='summary', conditions=dict(function=check_repo))
222 controller='summary', conditions=dict(function=check_repo))
198 routes_map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
223
224 rmap.connect('shortlog_home', '/{repo_name:.*}/shortlog',
199 controller='shortlog', conditions=dict(function=check_repo))
225 controller='shortlog', conditions=dict(function=check_repo))
200 routes_map.connect('branches_home', '/{repo_name:.*}/branches',
226
227 rmap.connect('branches_home', '/{repo_name:.*}/branches',
201 controller='branches', conditions=dict(function=check_repo))
228 controller='branches', conditions=dict(function=check_repo))
202 routes_map.connect('tags_home', '/{repo_name:.*}/tags',
229
230 rmap.connect('tags_home', '/{repo_name:.*}/tags',
203 controller='tags', conditions=dict(function=check_repo))
231 controller='tags', conditions=dict(function=check_repo))
204 routes_map.connect('changelog_home', '/{repo_name:.*}/changelog',
232
233 rmap.connect('changelog_home', '/{repo_name:.*}/changelog',
205 controller='changelog', conditions=dict(function=check_repo))
234 controller='changelog', conditions=dict(function=check_repo))
206 routes_map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
235
236 rmap.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
207 controller='files', revision='tip', f_path='',
237 controller='files', revision='tip', f_path='',
208 conditions=dict(function=check_repo))
238 conditions=dict(function=check_repo))
209 routes_map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
239
240 rmap.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
210 controller='files', action='diff', revision='tip', f_path='',
241 controller='files', action='diff', revision='tip', f_path='',
211 conditions=dict(function=check_repo))
242 conditions=dict(function=check_repo))
212 routes_map.connect('files_rawfile_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
243
213 controller='files', action='rawfile', revision='tip', f_path='',
244 rmap.connect('files_rawfile_home',
214 conditions=dict(function=check_repo))
245 '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
215 routes_map.connect('files_raw_home', '/{repo_name:.*}/raw/{revision}/{f_path:.*}',
246 controller='files', action='rawfile', revision='tip',
216 controller='files', action='raw', revision='tip', f_path='',
247 f_path='', conditions=dict(function=check_repo))
217 conditions=dict(function=check_repo))
248
218 routes_map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
249 rmap.connect('files_raw_home',
219 controller='files', action='annotate', revision='tip', f_path='',
250 '/{repo_name:.*}/raw/{revision}/{f_path:.*}',
220 conditions=dict(function=check_repo))
251 controller='files', action='raw', revision='tip', f_path='',
221 routes_map.connect('files_archive_home', '/{repo_name:.*}/archive/{fname}',
252 conditions=dict(function=check_repo))
253
254 rmap.connect('files_annotate_home',
255 '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
256 controller='files', action='annotate', revision='tip',
257 f_path='', conditions=dict(function=check_repo))
258
259 rmap.connect('files_archive_home', '/{repo_name:.*}/archive/{fname}',
222 controller='files', action='archivefile',
260 controller='files', action='archivefile',
223 conditions=dict(function=check_repo))
261 conditions=dict(function=check_repo))
224 routes_map.connect('repo_settings_delete', '/{repo_name:.*}/settings',
262
263 rmap.connect('repo_settings_delete', '/{repo_name:.*}/settings',
225 controller='settings', action="delete",
264 controller='settings', action="delete",
226 conditions=dict(method=["DELETE"], function=check_repo))
265 conditions=dict(method=["DELETE"], function=check_repo))
227 routes_map.connect('repo_settings_update', '/{repo_name:.*}/settings',
266
267 rmap.connect('repo_settings_update', '/{repo_name:.*}/settings',
228 controller='settings', action="update",
268 controller='settings', action="update",
229 conditions=dict(method=["PUT"], function=check_repo))
269 conditions=dict(method=["PUT"], function=check_repo))
230 routes_map.connect('repo_settings_home', '/{repo_name:.*}/settings',
270
271 rmap.connect('repo_settings_home', '/{repo_name:.*}/settings',
231 controller='settings', action='index',
272 controller='settings', action='index',
232 conditions=dict(function=check_repo))
273 conditions=dict(function=check_repo))
233
274
234 routes_map.connect('repo_fork_create_home', '/{repo_name:.*}/fork',
275 rmap.connect('repo_fork_create_home', '/{repo_name:.*}/fork',
235 controller='settings', action='fork_create',
276 controller='settings', action='fork_create',
236 conditions=dict(function=check_repo, method=["POST"]))
277 conditions=dict(function=check_repo, method=["POST"]))
237 routes_map.connect('repo_fork_home', '/{repo_name:.*}/fork',
278
279 rmap.connect('repo_fork_home', '/{repo_name:.*}/fork',
238 controller='settings', action='fork',
280 controller='settings', action='fork',
239 conditions=dict(function=check_repo))
281 conditions=dict(function=check_repo))
240
282
241 return routes_map
283 return rmap
General Comments 0
You need to be logged in to leave comments. Login now