6ec64e49affec351e2ad9accfb15ec63a882b6d1
[zzz-floof.git] / floof / config / routing.py
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 pylons import config
8 from routes import Mapper
9
10 def make_map():
11 """Create, configure and return the routes Mapper"""
12 map = Mapper(directory=config['pylons.paths']['controllers'],
13 always_scan=config['debug'], explicit=True)
14 map.minimization = False
15 # explicit = True disables a broken feature called "route memory",
16 # where it adds everything matched in the current request as default variables
17 # for the next one. This is wrong because it doesn't invalidate things lower down in
18 # the hierarchy when higher up things change. Rails port failure.
19 # NOTE: this also disables actions defaulting to index, sorry.
20
21 require_POST = dict(conditions={'method': ['POST']})
22
23 # The ErrorController route (handles 404/500 error pages); it should
24 # likely stay at the top, ensuring it can always be resolved
25 map.connect('/error/{action}', controller='error')
26 map.connect('/error/{action}/{id}', controller='error')
27
28 map.connect('/', controller='main', action='index')
29
30 # User stuff
31 map.connect('/account/login', controller='account', action='login')
32 map.connect('/account/login_begin', controller='account', action='login_begin', **require_POST)
33 map.connect('/account/login_finish', controller='account', action='login_finish')
34 map.connect('/account/logout', controller='account', action='logout', **require_POST)
35 map.connect('/account/register', controller='account', action='register')
36 map.connect('/account/register_finish', controller='account', action='register_finish', **require_POST)
37
38 map.connect('/users', controller='users', action='list')
39 map.connect('/users/{name}', controller='users', action='view')
40
41 # Art stuff
42 map.connect('/art/new', controller='art', action='new')
43 map.connect('/art/upload', controller='art', action='upload')
44 map.connect('show_art', '/art/{id}', controller='art', action='show')
45 map.connect('/art/{id}/tag', controller='art', action='tag')
46
47 map.connect('/tag/{id}/delete', controller='tag', action='delete')
48
49 map.connect('search', '/search', controller='search', action='index')
50 map.connect('/search/list', controller='search', action='list')
51
52
53 # default routing is back so we can test stuff.
54 # please don't take it away until we have some more core features in.
55 map.connect('/{controller}/{action}')
56 map.connect('/{controller}/{action}/{id}')
57
58 return map