##// END OF EJS Templates
fixed 404s added extra validator for magic repo_name path in routes
marcink -
r300:8f7b8e96 default
parent child Browse files
Show More
@@ -63,6 +63,7 b' def load_environment(global_conf, app_co'
63 init_model(sa_engine_db1)
63 init_model(sa_engine_db1)
64 repo2db_mapper(_get_repos_cached_initial(config['pylons.app_globals']))
64 repo2db_mapper(_get_repos_cached_initial(config['pylons.app_globals']))
65 set_available_permissions(config)
65 set_available_permissions(config)
66 config['base_path'] = config['pylons.app_globals'].base_path
66 # CONFIGURATION OPTIONS HERE (note: all config options will override
67 # CONFIGURATION OPTIONS HERE (note: all config options will override
67 # any Pylons config options)
68 # any Pylons config options)
68
69
@@ -5,6 +5,7 b' may take precedent over the more generic'
5 refer to the routes manual at http://routes.groovie.org/docs/
5 refer to the routes manual at http://routes.groovie.org/docs/
6 """
6 """
7 from routes import Mapper
7 from routes import Mapper
8 from pylons_app.lib.utils import check_repo as cr
8
9
9 def make_map(config):
10 def make_map(config):
10 """Create, configure and return the routes Mapper"""
11 """Create, configure and return the routes Mapper"""
@@ -21,7 +22,15 b' def make_map(config):'
21 # CUSTOM ROUTES HERE
22 # CUSTOM ROUTES HERE
22 map.connect('hg_home', '/', controller='hg', action='index')
23 map.connect('hg_home', '/', controller='hg', action='index')
23
24
24
25 def check_repo(environ, match_dict):
26 """
27 check for valid repository for proper 404 handling
28 @param environ:
29 @param match_dict:
30 """
31 repo_name = match_dict.get('repo_name')
32 return not cr(repo_name, config['base_path'])
33
25 #REST routes
34 #REST routes
26 with map.submapper(path_prefix='/_admin', controller='repos') as m:
35 with map.submapper(path_prefix='/_admin', controller='repos') as m:
27 m.connect("repos", "/repos",
36 m.connect("repos", "/repos",
@@ -36,20 +45,27 b' def make_map(config):'
36 m.connect("formatted_new_repo", "/repos/new.{format}",
45 m.connect("formatted_new_repo", "/repos/new.{format}",
37 action="new", conditions=dict(method=["GET"]))
46 action="new", conditions=dict(method=["GET"]))
38 m.connect("/repos/{repo_name:.*}",
47 m.connect("/repos/{repo_name:.*}",
39 action="update", conditions=dict(method=["PUT"]))
48 action="update", conditions=dict(method=["PUT"],
49 function=check_repo))
40 m.connect("/repos/{repo_name:.*}",
50 m.connect("/repos/{repo_name:.*}",
41 action="delete", conditions=dict(method=["DELETE"]))
51 action="delete", conditions=dict(method=["DELETE"],
52 function=check_repo))
42 m.connect("edit_repo", "/repos/{repo_name:.*}/edit",
53 m.connect("edit_repo", "/repos/{repo_name:.*}/edit",
43 action="edit", conditions=dict(method=["GET"]))
54 action="edit", conditions=dict(method=["GET"],
55 function=check_repo))
44 m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit",
56 m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit",
45 action="edit", conditions=dict(method=["GET"]))
57 action="edit", conditions=dict(method=["GET"],
58 function=check_repo))
46 m.connect("repo", "/repos/{repo_name:.*}",
59 m.connect("repo", "/repos/{repo_name:.*}",
47 action="show", conditions=dict(method=["GET"]))
60 action="show", conditions=dict(method=["GET"],
61 function=check_repo))
48 m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}",
62 m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}",
49 action="show", conditions=dict(method=["GET"]))
63 action="show", conditions=dict(method=["GET"],
64 function=check_repo))
50 #ajax delete repo perm user
65 #ajax delete repo perm user
51 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}",
66 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}",
52 action="delete_perm_user", conditions=dict(method=["DELETE"]))
67 action="delete_perm_user", conditions=dict(method=["DELETE"],
68 function=check_repo))
53
69
54 map.resource('user', 'users', path_prefix='/_admin')
70 map.resource('user', 'users', path_prefix='/_admin')
55 map.resource('permission', 'permissions', path_prefix='/_admin')
71 map.resource('permission', 'permissions', path_prefix='/_admin')
@@ -62,33 +78,41 b' def make_map(config):'
62
78
63 #FEEDS
79 #FEEDS
64 map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
80 map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
65 controller='feed', action='rss')
81 controller='feed', action='rss',
82 conditions=dict(function=check_repo))
66 map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
83 map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
67 controller='feed', action='atom')
84 controller='feed', action='atom',
85 conditions=dict(function=check_repo))
68
86
69 map.connect('login_home', '/login', controller='login')
87 map.connect('login_home', '/login', controller='login')
70 map.connect('logout_home', '/logout', controller='login', action='logout')
88 map.connect('logout_home', '/logout', controller='login', action='logout')
71
89
72 map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
90 map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
73 controller='changeset', revision='tip')
91 controller='changeset', revision='tip',
92 conditions=dict(function=check_repo))
74 map.connect('summary_home', '/{repo_name:.*}/summary',
93 map.connect('summary_home', '/{repo_name:.*}/summary',
75 controller='summary')
94 controller='summary', conditions=dict(function=check_repo))
76 map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
95 map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
77 controller='shortlog')
96 controller='shortlog', conditions=dict(function=check_repo))
78 map.connect('branches_home', '/{repo_name:.*}/branches',
97 map.connect('branches_home', '/{repo_name:.*}/branches',
79 controller='branches')
98 controller='branches', conditions=dict(function=check_repo))
80 map.connect('tags_home', '/{repo_name:.*}/tags',
99 map.connect('tags_home', '/{repo_name:.*}/tags',
81 controller='tags')
100 controller='tags', conditions=dict(function=check_repo))
82 map.connect('changelog_home', '/{repo_name:.*}/changelog',
101 map.connect('changelog_home', '/{repo_name:.*}/changelog',
83 controller='changelog')
102 controller='changelog', conditions=dict(function=check_repo))
84 map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
103 map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
85 controller='files', revision='tip', f_path='')
104 controller='files', revision='tip', f_path='',
105 conditions=dict(function=check_repo))
86 map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
106 map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
87 controller='files', action='diff', revision='tip', f_path='')
107 controller='files', action='diff', revision='tip', f_path='',
108 conditions=dict(function=check_repo))
88 map.connect('files_raw_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
109 map.connect('files_raw_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
89 controller='files', action='rawfile', revision='tip', f_path='')
110 controller='files', action='rawfile', revision='tip', f_path='',
111 conditions=dict(function=check_repo))
90 map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
112 map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
91 controller='files', action='annotate', revision='tip', f_path='')
113 controller='files', action='annotate', revision='tip', f_path='',
114 conditions=dict(function=check_repo))
92 map.connect('files_archive_home', '/{repo_name:.*}/archive/{revision}/{fileformat}',
115 map.connect('files_archive_home', '/{repo_name:.*}/archive/{revision}/{fileformat}',
93 controller='files', action='archivefile', revision='tip')
116 controller='files', action='archivefile', revision='tip',
117 conditions=dict(function=check_repo))
94 return map
118 return map
General Comments 0
You need to be logged in to leave comments. Login now