comparison rhodecode/config/routing.py @ 547:1e757ac98988

renamed project to rhodecode
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 06 Oct 2010 03:18:16 +0200
parents pylons_app/config/routing.py@a08f610e545e
children 5cc96df705b9
comparison
equal deleted inserted replaced
546:7c2f5e4d7bbf 547:1e757ac98988
1 """Routes configuration
2
3 The more specific and detailed routes should be defined first so they
4 may take precedent over the more generic routes. For more information
5 refer to the routes manual at http://routes.groovie.org/docs/
6 """
7 from __future__ import with_statement
8 from routes import Mapper
9 from rhodecode.lib.utils import check_repo_fast as cr
10
11 def make_map(config):
12 """Create, configure and return the routes Mapper"""
13 map = Mapper(directory=config['pylons.paths']['controllers'],
14 always_scan=config['debug'])
15 map.minimization = False
16 map.explicit = False
17
18 # The ErrorController route (handles 404/500 error pages); it should
19 # likely stay at the top, ensuring it can always be resolved
20 map.connect('/error/{action}', controller='error')
21 map.connect('/error/{action}/{id}', controller='error')
22
23 # CUSTOM ROUTES HERE
24 map.connect('hg_home', '/', controller='hg', action='index')
25
26 def check_repo(environ, match_dict):
27 """
28 check for valid repository for proper 404 handling
29 @param environ:
30 @param match_dict:
31 """
32 repo_name = match_dict.get('repo_name')
33 return not cr(repo_name, config['base_path'])
34
35 #REST REPO MAP
36 with map.submapper(path_prefix='/_admin', controller='admin/repos') as m:
37 m.connect("repos", "/repos",
38 action="create", conditions=dict(method=["POST"]))
39 m.connect("repos", "/repos",
40 action="index", conditions=dict(method=["GET"]))
41 m.connect("formatted_repos", "/repos.{format}",
42 action="index",
43 conditions=dict(method=["GET"]))
44 m.connect("new_repo", "/repos/new",
45 action="new", conditions=dict(method=["GET"]))
46 m.connect("formatted_new_repo", "/repos/new.{format}",
47 action="new", conditions=dict(method=["GET"]))
48 m.connect("/repos/{repo_name:.*}",
49 action="update", conditions=dict(method=["PUT"],
50 function=check_repo))
51 m.connect("/repos/{repo_name:.*}",
52 action="delete", conditions=dict(method=["DELETE"],
53 function=check_repo))
54 m.connect("edit_repo", "/repos/{repo_name:.*}/edit",
55 action="edit", conditions=dict(method=["GET"],
56 function=check_repo))
57 m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit",
58 action="edit", conditions=dict(method=["GET"],
59 function=check_repo))
60 m.connect("repo", "/repos/{repo_name:.*}",
61 action="show", conditions=dict(method=["GET"],
62 function=check_repo))
63 m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}",
64 action="show", conditions=dict(method=["GET"],
65 function=check_repo))
66 #ajax delete repo perm user
67 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}",
68 action="delete_perm_user", conditions=dict(method=["DELETE"],
69 function=check_repo))
70
71 map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
72 map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin')
73
74 #REST SETTINGS MAP
75 with map.submapper(path_prefix='/_admin', controller='admin/settings') as m:
76 m.connect("admin_settings", "/settings",
77 action="create", conditions=dict(method=["POST"]))
78 m.connect("admin_settings", "/settings",
79 action="index", conditions=dict(method=["GET"]))
80 m.connect("formatted_admin_settings", "/settings.{format}",
81 action="index", conditions=dict(method=["GET"]))
82 m.connect("admin_new_setting", "/settings/new",
83 action="new", conditions=dict(method=["GET"]))
84 m.connect("formatted_admin_new_setting", "/settings/new.{format}",
85 action="new", conditions=dict(method=["GET"]))
86 m.connect("/settings/{setting_id}",
87 action="update", conditions=dict(method=["PUT"]))
88 m.connect("/settings/{setting_id}",
89 action="delete", conditions=dict(method=["DELETE"]))
90 m.connect("admin_edit_setting", "/settings/{setting_id}/edit",
91 action="edit", conditions=dict(method=["GET"]))
92 m.connect("formatted_admin_edit_setting", "/settings/{setting_id}.{format}/edit",
93 action="edit", conditions=dict(method=["GET"]))
94 m.connect("admin_setting", "/settings/{setting_id}",
95 action="show", conditions=dict(method=["GET"]))
96 m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}",
97 action="show", conditions=dict(method=["GET"]))
98 m.connect("admin_settings_my_account", "/my_account",
99 action="my_account", conditions=dict(method=["GET"]))
100 m.connect("admin_settings_my_account_update", "/my_account_update",
101 action="my_account_update", conditions=dict(method=["PUT"]))
102 m.connect("admin_settings_create_repository", "/create_repository",
103 action="create_repository", conditions=dict(method=["GET"]))
104
105 #ADMIN
106 with map.submapper(path_prefix='/_admin', controller='admin/admin') as m:
107 m.connect('admin_home', '', action='index')#main page
108 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
109 action='add_repo')
110 #SEARCH
111 map.connect('search', '/_admin/search', controller='search',)
112 map.connect('search_repo', '/_admin/search/{search_repo:.*}', controller='search')
113
114 #LOGIN/LOGOUT/REGISTER/SIGN IN
115 map.connect('login_home', '/_admin/login', controller='login')
116 map.connect('logout_home', '/_admin/logout', controller='login', action='logout')
117 map.connect('register', '/_admin/register', controller='login', action='register')
118 map.connect('reset_password', '/_admin/password_reset', controller='login', action='password_reset')
119
120 #FEEDS
121 map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
122 controller='feed', action='rss',
123 conditions=dict(function=check_repo))
124 map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
125 controller='feed', action='atom',
126 conditions=dict(function=check_repo))
127
128
129 #OTHERS
130 map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
131 controller='changeset', revision='tip',
132 conditions=dict(function=check_repo))
133 map.connect('raw_changeset_home', '/{repo_name:.*}/raw-changeset/{revision}',
134 controller='changeset', action='raw_changeset', revision='tip',
135 conditions=dict(function=check_repo))
136 map.connect('summary_home', '/{repo_name:.*}/summary',
137 controller='summary', conditions=dict(function=check_repo))
138 map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
139 controller='shortlog', conditions=dict(function=check_repo))
140 map.connect('branches_home', '/{repo_name:.*}/branches',
141 controller='branches', conditions=dict(function=check_repo))
142 map.connect('tags_home', '/{repo_name:.*}/tags',
143 controller='tags', conditions=dict(function=check_repo))
144 map.connect('changelog_home', '/{repo_name:.*}/changelog',
145 controller='changelog', conditions=dict(function=check_repo))
146 map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
147 controller='files', revision='tip', f_path='',
148 conditions=dict(function=check_repo))
149 map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
150 controller='files', action='diff', revision='tip', f_path='',
151 conditions=dict(function=check_repo))
152 map.connect('files_rawfile_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
153 controller='files', action='rawfile', revision='tip', f_path='',
154 conditions=dict(function=check_repo))
155 map.connect('files_raw_home', '/{repo_name:.*}/raw/{revision}/{f_path:.*}',
156 controller='files', action='raw', revision='tip', f_path='',
157 conditions=dict(function=check_repo))
158 map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
159 controller='files', action='annotate', revision='tip', f_path='',
160 conditions=dict(function=check_repo))
161 map.connect('files_archive_home', '/{repo_name:.*}/archive/{revision}/{fileformat}',
162 controller='files', action='archivefile', revision='tip',
163 conditions=dict(function=check_repo))
164 map.connect('repo_settings_delete', '/{repo_name:.*}/settings',
165 controller='settings', action="delete",
166 conditions=dict(method=["DELETE"], function=check_repo))
167 map.connect('repo_settings_update', '/{repo_name:.*}/settings',
168 controller='settings', action="update",
169 conditions=dict(method=["PUT"], function=check_repo))
170 map.connect('repo_settings_home', '/{repo_name:.*}/settings',
171 controller='settings', action='index',
172 conditions=dict(function=check_repo))
173
174 map.connect('repo_fork_create_home', '/{repo_name:.*}/fork',
175 controller='settings', action='fork_create',
176 conditions=dict(function=check_repo, method=["POST"]))
177 map.connect('repo_fork_home', '/{repo_name:.*}/fork',
178 controller='settings', action='fork',
179 conditions=dict(function=check_repo))
180
181 return map