Show More
@@ -1,86 +1,86 b'' | |||||
1 | """Pylons environment configuration""" |
|
1 | """Pylons environment configuration""" | |
2 |
|
2 | |||
3 | import os |
|
3 | import os | |
4 | import logging |
|
4 | import logging | |
5 |
|
5 | |||
6 | from mako.lookup import TemplateLookup |
|
6 | from mako.lookup import TemplateLookup | |
7 | from pylons.configuration import PylonsConfig |
|
7 | from pylons.configuration import PylonsConfig | |
8 | from pylons.error import handle_mako_error |
|
8 | from pylons.error import handle_mako_error | |
|
9 | from sqlalchemy import engine_from_config | |||
9 |
|
10 | |||
10 | import rhodecode.lib.app_globals as app_globals |
|
11 | import rhodecode.lib.app_globals as app_globals | |
11 | import rhodecode.lib.helpers |
|
12 | import rhodecode.lib.helpers | |
12 |
|
13 | |||
13 | from rhodecode.config.routing import make_map |
|
14 | from rhodecode.config.routing import make_map | |
14 | from rhodecode.lib import celerypylons |
|
15 | from rhodecode.lib import celerypylons | |
15 | from rhodecode.lib.auth import set_available_permissions, set_base_path |
|
16 | from rhodecode.lib.auth import set_available_permissions, set_base_path | |
16 | from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config |
|
17 | from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config | |
17 | from rhodecode.model import init_model |
|
18 | from rhodecode.model import init_model | |
18 | from rhodecode.model.scm import ScmModel |
|
19 | from rhodecode.model.scm import ScmModel | |
19 | from sqlalchemy import engine_from_config |
|
20 | from rhodecode.lib.timerproxy import TimerProxy | |
20 |
|
21 | |||
21 | log = logging.getLogger(__name__) |
|
22 | log = logging.getLogger(__name__) | |
22 |
|
23 | |||
23 | def load_environment(global_conf, app_conf, initial=False): |
|
24 | def load_environment(global_conf, app_conf, initial=False): | |
24 | """Configure the Pylons environment via the ``pylons.config`` |
|
25 | """Configure the Pylons environment via the ``pylons.config`` | |
25 | object |
|
26 | object | |
26 | """ |
|
27 | """ | |
27 | config = PylonsConfig() |
|
28 | config = PylonsConfig() | |
28 |
|
29 | |||
29 | # Pylons paths |
|
30 | # Pylons paths | |
30 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
|
31 | root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
31 | paths = dict(root=root, |
|
32 | paths = dict(root=root, | |
32 | controllers=os.path.join(root, 'controllers'), |
|
33 | controllers=os.path.join(root, 'controllers'), | |
33 | static_files=os.path.join(root, 'public'), |
|
34 | static_files=os.path.join(root, 'public'), | |
34 | templates=[os.path.join(root, 'templates')]) |
|
35 | templates=[os.path.join(root, 'templates')]) | |
35 |
|
36 | |||
36 | # Initialize config with the basic options |
|
37 | # Initialize config with the basic options | |
37 | config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) |
|
38 | config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) | |
38 |
|
39 | |||
39 | config['routes.map'] = make_map(config) |
|
40 | config['routes.map'] = make_map(config) | |
40 | config['pylons.app_globals'] = app_globals.Globals(config) |
|
41 | config['pylons.app_globals'] = app_globals.Globals(config) | |
41 | config['pylons.h'] = rhodecode.lib.helpers |
|
42 | config['pylons.h'] = rhodecode.lib.helpers | |
42 |
|
43 | |||
43 | # Setup cache object as early as possible |
|
44 | # Setup cache object as early as possible | |
44 | import pylons |
|
45 | import pylons | |
45 | pylons.cache._push_object(config['pylons.app_globals'].cache) |
|
46 | pylons.cache._push_object(config['pylons.app_globals'].cache) | |
46 |
|
47 | |||
47 | # Create the Mako TemplateLookup, with the default auto-escaping |
|
48 | # Create the Mako TemplateLookup, with the default auto-escaping | |
48 | config['pylons.app_globals'].mako_lookup = TemplateLookup( |
|
49 | config['pylons.app_globals'].mako_lookup = TemplateLookup( | |
49 | directories=paths['templates'], |
|
50 | directories=paths['templates'], | |
50 | error_handler=handle_mako_error, |
|
51 | error_handler=handle_mako_error, | |
51 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
|
52 | module_directory=os.path.join(app_conf['cache_dir'], 'templates'), | |
52 | input_encoding='utf-8', default_filters=['escape'], |
|
53 | input_encoding='utf-8', default_filters=['escape'], | |
53 | imports=['from webhelpers.html import escape']) |
|
54 | imports=['from webhelpers.html import escape']) | |
54 |
|
55 | |||
55 | #sets the c attribute access when don't existing attribute are accessed |
|
56 | #sets the c attribute access when don't existing attribute are accessed | |
56 | config['pylons.strict_tmpl_context'] = True |
|
57 | config['pylons.strict_tmpl_context'] = True | |
57 | test = os.path.split(config['__file__'])[-1] == 'test.ini' |
|
58 | test = os.path.split(config['__file__'])[-1] == 'test.ini' | |
58 | if test: |
|
59 | if test: | |
59 | from rhodecode.lib.utils import create_test_env, create_test_index |
|
60 | from rhodecode.lib.utils import create_test_env, create_test_index | |
60 | from rhodecode.tests import TESTS_TMP_PATH |
|
61 | from rhodecode.tests import TESTS_TMP_PATH | |
61 | create_test_env(TESTS_TMP_PATH, config) |
|
62 | create_test_env(TESTS_TMP_PATH, config) | |
62 | create_test_index(TESTS_TMP_PATH, True) |
|
63 | create_test_index(TESTS_TMP_PATH, True) | |
63 |
|
64 | |||
64 | #MULTIPLE DB configs |
|
65 | #MULTIPLE DB configs | |
65 | # Setup the SQLAlchemy database engine |
|
66 | # Setup the SQLAlchemy database engine | |
66 | if config['debug'] and not test: |
|
67 | if config['debug'] and not test: | |
67 | #use query time debugging. |
|
68 | #use query time debugging. | |
68 | from rhodecode.lib.timerproxy import TimerProxy |
|
|||
69 | sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.', |
|
69 | sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.', | |
70 | proxy=TimerProxy()) |
|
70 | proxy=TimerProxy()) | |
71 | else: |
|
71 | else: | |
72 | sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') |
|
72 | sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') | |
73 |
|
73 | |||
74 | init_model(sa_engine_db1) |
|
74 | init_model(sa_engine_db1) | |
75 | #init baseui |
|
75 | #init baseui | |
76 | config['pylons.app_globals'].baseui = make_ui('db') |
|
76 | config['pylons.app_globals'].baseui = make_ui('db') | |
77 |
|
77 | |||
78 | g = config['pylons.app_globals'] |
|
78 | g = config['pylons.app_globals'] | |
79 | repo2db_mapper(ScmModel().repo_scan(g.paths[0][1], g.baseui)) |
|
79 | repo2db_mapper(ScmModel().repo_scan(g.paths[0][1], g.baseui)) | |
80 | set_available_permissions(config) |
|
80 | set_available_permissions(config) | |
81 | set_base_path(config) |
|
81 | set_base_path(config) | |
82 | set_rhodecode_config(config) |
|
82 | set_rhodecode_config(config) | |
83 | # CONFIGURATION OPTIONS HERE (note: all config options will override |
|
83 | # CONFIGURATION OPTIONS HERE (note: all config options will override | |
84 | # any Pylons config options) |
|
84 | # any Pylons config options) | |
85 |
|
85 | |||
86 | return config |
|
86 | return config |
@@ -1,76 +1,79 b'' | |||||
1 | """Pylons middleware initialization""" |
|
1 | """Pylons middleware initialization""" | |
|
2 | ||||
2 | from beaker.middleware import SessionMiddleware |
|
3 | from beaker.middleware import SessionMiddleware | |
|
4 | from routes.middleware import RoutesMiddleware | |||
3 | from paste.cascade import Cascade |
|
5 | from paste.cascade import Cascade | |
4 | from paste.registry import RegistryManager |
|
6 | from paste.registry import RegistryManager | |
5 | from paste.urlparser import StaticURLParser |
|
7 | from paste.urlparser import StaticURLParser | |
6 | from paste.deploy.converters import asbool |
|
8 | from paste.deploy.converters import asbool | |
|
9 | from paste.gzipper import make_gzip_middleware | |||
|
10 | ||||
7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect |
|
11 | from pylons.middleware import ErrorHandler, StatusCodeRedirect | |
8 | from pylons.wsgiapp import PylonsApp |
|
12 | from pylons.wsgiapp import PylonsApp | |
9 | from routes.middleware import RoutesMiddleware |
|
13 | ||
10 | from rhodecode.lib.middleware.simplehg import SimpleHg |
|
14 | from rhodecode.lib.middleware.simplehg import SimpleHg | |
11 | from rhodecode.lib.middleware.simplegit import SimpleGit |
|
15 | from rhodecode.lib.middleware.simplegit import SimpleGit | |
12 | from rhodecode.lib.middleware.https_fixup import HttpsFixup |
|
16 | from rhodecode.lib.middleware.https_fixup import HttpsFixup | |
13 | from rhodecode.config.environment import load_environment |
|
17 | from rhodecode.config.environment import load_environment | |
14 | from paste.gzipper import make_gzip_middleware |
|
|||
15 |
|
18 | |||
16 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): |
|
19 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): | |
17 | """Create a Pylons WSGI application and return it |
|
20 | """Create a Pylons WSGI application and return it | |
18 |
|
21 | |||
19 | ``global_conf`` |
|
22 | ``global_conf`` | |
20 | The inherited configuration for this application. Normally from |
|
23 | The inherited configuration for this application. Normally from | |
21 | the [DEFAULT] section of the Paste ini file. |
|
24 | the [DEFAULT] section of the Paste ini file. | |
22 |
|
25 | |||
23 | ``full_stack`` |
|
26 | ``full_stack`` | |
24 | Whether or not this application provides a full WSGI stack (by |
|
27 | Whether or not this application provides a full WSGI stack (by | |
25 | default, meaning it handles its own exceptions and errors). |
|
28 | default, meaning it handles its own exceptions and errors). | |
26 | Disable full_stack when this application is "managed" by |
|
29 | Disable full_stack when this application is "managed" by | |
27 | another WSGI middleware. |
|
30 | another WSGI middleware. | |
28 |
|
31 | |||
29 | ``app_conf`` |
|
32 | ``app_conf`` | |
30 | The application's local configuration. Normally specified in |
|
33 | The application's local configuration. Normally specified in | |
31 | the [app:<name>] section of the Paste ini file (where <name> |
|
34 | the [app:<name>] section of the Paste ini file (where <name> | |
32 | defaults to main). |
|
35 | defaults to main). | |
33 |
|
36 | |||
34 | """ |
|
37 | """ | |
35 | # Configure the Pylons environment |
|
38 | # Configure the Pylons environment | |
36 | config = load_environment(global_conf, app_conf) |
|
39 | config = load_environment(global_conf, app_conf) | |
37 |
|
40 | |||
38 | # The Pylons WSGI app |
|
41 | # The Pylons WSGI app | |
39 | app = PylonsApp(config=config) |
|
42 | app = PylonsApp(config=config) | |
40 |
|
43 | |||
41 | # Routing/Session/Cache Middleware |
|
44 | # Routing/Session/Cache Middleware | |
42 | app = RoutesMiddleware(app, config['routes.map']) |
|
45 | app = RoutesMiddleware(app, config['routes.map']) | |
43 | app = SessionMiddleware(app, config) |
|
46 | app = SessionMiddleware(app, config) | |
44 |
|
47 | |||
45 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) |
|
48 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) | |
46 |
|
49 | |||
47 | app = SimpleHg(app, config) |
|
50 | app = SimpleHg(app, config) | |
48 | app = SimpleGit(app, config) |
|
51 | app = SimpleGit(app, config) | |
49 |
|
52 | |||
50 | if asbool(full_stack): |
|
53 | if asbool(full_stack): | |
51 | # Handle Python exceptions |
|
54 | # Handle Python exceptions | |
52 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) |
|
55 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) | |
53 |
|
56 | |||
54 | # Display error documents for 401, 403, 404 status codes (and |
|
57 | # Display error documents for 401, 403, 404 status codes (and | |
55 | # 500 when debug is disabled) |
|
58 | # 500 when debug is disabled) | |
56 | if asbool(config['debug']): |
|
59 | if asbool(config['debug']): | |
57 | app = StatusCodeRedirect(app) |
|
60 | app = StatusCodeRedirect(app) | |
58 | else: |
|
61 | else: | |
59 | app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) |
|
62 | app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) | |
60 |
|
63 | |||
61 | #enable https redirets based on HTTP_X_URL_SCHEME set by proxy |
|
64 | #enable https redirets based on HTTP_X_URL_SCHEME set by proxy | |
62 | app = HttpsFixup(app, config) |
|
65 | app = HttpsFixup(app, config) | |
63 |
|
66 | |||
64 | # Establish the Registry for this application |
|
67 | # Establish the Registry for this application | |
65 | app = RegistryManager(app) |
|
68 | app = RegistryManager(app) | |
66 |
|
69 | |||
67 | if asbool(static_files): |
|
70 | if asbool(static_files): | |
68 | # Serve static files |
|
71 | # Serve static files | |
69 | static_app = StaticURLParser(config['pylons.paths']['static_files']) |
|
72 | static_app = StaticURLParser(config['pylons.paths']['static_files']) | |
70 | app = Cascade([static_app, app]) |
|
73 | app = Cascade([static_app, app]) | |
71 | app = make_gzip_middleware(app, global_conf, compress_level=1) |
|
74 | app = make_gzip_middleware(app, global_conf, compress_level=1) | |
72 |
|
75 | |||
73 | app.config = config |
|
76 | app.config = config | |
74 |
|
77 | |||
75 | return app |
|
78 | return app | |
76 |
|
79 |
@@ -1,224 +1,225 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Routes configuration |
|
2 | Routes configuration | |
3 |
|
3 | |||
4 | The more specific and detailed routes should be defined first so they |
|
4 | The more specific and detailed routes should be defined first so they | |
5 | may take precedent over the more generic routes. For more information |
|
5 | may take precedent over the more generic routes. For more information | |
6 | refer to the routes manual at http://routes.groovie.org/docs/ |
|
6 | refer to the routes manual at http://routes.groovie.org/docs/ | |
7 | """ |
|
7 | """ | |
8 | from __future__ import with_statement |
|
8 | from __future__ import with_statement | |
9 | from routes import Mapper |
|
9 | from routes import Mapper | |
10 | from rhodecode.lib.utils import check_repo_fast as cr |
|
10 | from rhodecode.lib.utils import check_repo_fast as cr | |
11 |
|
11 | |||
12 | def make_map(config): |
|
12 | def make_map(config): | |
13 | """Create, configure and return the routes Mapper""" |
|
13 | """Create, configure and return the routes Mapper""" | |
14 | map = Mapper(directory=config['pylons.paths']['controllers'], |
|
14 | routes_map = Mapper(directory=config['pylons.paths']['controllers'], | |
15 | always_scan=config['debug']) |
|
15 | always_scan=config['debug']) | |
16 | map.minimization = False |
|
16 | routes_map.minimization = False | |
17 | map.explicit = False |
|
17 | routes_map.explicit = False | |
18 |
|
18 | |||
19 | def check_repo(environ, match_dict): |
|
19 | def check_repo(environ, match_dict): | |
20 | """ |
|
20 | """ | |
21 | check for valid repository for proper 404 handling |
|
21 | check for valid repository for proper 404 handling | |
|
22 | ||||
22 | :param environ: |
|
23 | :param environ: | |
23 | :param match_dict: |
|
24 | :param match_dict: | |
24 | """ |
|
25 | """ | |
25 | repo_name = match_dict.get('repo_name') |
|
26 | repo_name = match_dict.get('repo_name') | |
26 | return not cr(repo_name, config['base_path']) |
|
27 | return not cr(repo_name, config['base_path']) | |
27 |
|
28 | |||
28 | # The ErrorController route (handles 404/500 error pages); it should |
|
29 | # The ErrorController route (handles 404/500 error pages); it should | |
29 | # likely stay at the top, ensuring it can always be resolved |
|
30 | # likely stay at the top, ensuring it can always be resolved | |
30 | map.connect('/error/{action}', controller='error') |
|
31 | routes_map.connect('/error/{action}', controller='error') | |
31 | map.connect('/error/{action}/{id}', controller='error') |
|
32 | routes_map.connect('/error/{action}/{id}', controller='error') | |
32 |
|
33 | |||
33 | #========================================================================== |
|
34 | #========================================================================== | |
34 | # CUSTOM ROUTES HERE |
|
35 | # CUSTOM ROUTES HERE | |
35 | #========================================================================== |
|
36 | #========================================================================== | |
36 |
|
37 | |||
37 | #MAIN PAGE |
|
38 | #MAIN PAGE | |
38 | map.connect('home', '/', controller='home', action='index') |
|
39 | routes_map.connect('home', '/', controller='home', action='index') | |
39 | map.connect('bugtracker', "http://bitbucket.org/marcinkuzminski/rhodecode/issues", _static=True) |
|
40 | routes_map.connect('bugtracker', "http://bitbucket.org/marcinkuzminski/rhodecode/issues", _static=True) | |
40 | map.connect('gpl_license', "http://www.gnu.org/licenses/gpl.html", _static=True) |
|
41 | routes_map.connect('gpl_license', "http://www.gnu.org/licenses/gpl.html", _static=True) | |
41 | #ADMIN REPOSITORY REST ROUTES |
|
42 | #ADMIN REPOSITORY REST ROUTES | |
42 | with map.submapper(path_prefix='/_admin', controller='admin/repos') as m: |
|
43 | with routes_map.submapper(path_prefix='/_admin', controller='admin/repos') as m: | |
43 | m.connect("repos", "/repos", |
|
44 | m.connect("repos", "/repos", | |
44 | action="create", conditions=dict(method=["POST"])) |
|
45 | action="create", conditions=dict(method=["POST"])) | |
45 | m.connect("repos", "/repos", |
|
46 | m.connect("repos", "/repos", | |
46 | action="index", conditions=dict(method=["GET"])) |
|
47 | action="index", conditions=dict(method=["GET"])) | |
47 | m.connect("formatted_repos", "/repos.{format}", |
|
48 | m.connect("formatted_repos", "/repos.{format}", | |
48 | action="index", |
|
49 | action="index", | |
49 | conditions=dict(method=["GET"])) |
|
50 | conditions=dict(method=["GET"])) | |
50 | m.connect("new_repo", "/repos/new", |
|
51 | m.connect("new_repo", "/repos/new", | |
51 | action="new", conditions=dict(method=["GET"])) |
|
52 | action="new", conditions=dict(method=["GET"])) | |
52 | m.connect("formatted_new_repo", "/repos/new.{format}", |
|
53 | m.connect("formatted_new_repo", "/repos/new.{format}", | |
53 | action="new", conditions=dict(method=["GET"])) |
|
54 | action="new", conditions=dict(method=["GET"])) | |
54 | m.connect("/repos/{repo_name:.*}", |
|
55 | m.connect("/repos/{repo_name:.*}", | |
55 | action="update", conditions=dict(method=["PUT"], |
|
56 | action="update", conditions=dict(method=["PUT"], | |
56 | function=check_repo)) |
|
57 | function=check_repo)) | |
57 | m.connect("/repos/{repo_name:.*}", |
|
58 | m.connect("/repos/{repo_name:.*}", | |
58 | action="delete", conditions=dict(method=["DELETE"], |
|
59 | action="delete", conditions=dict(method=["DELETE"], | |
59 | function=check_repo)) |
|
60 | function=check_repo)) | |
60 | m.connect("edit_repo", "/repos/{repo_name:.*}/edit", |
|
61 | m.connect("edit_repo", "/repos/{repo_name:.*}/edit", | |
61 | action="edit", conditions=dict(method=["GET"], |
|
62 | action="edit", conditions=dict(method=["GET"], | |
62 | function=check_repo)) |
|
63 | function=check_repo)) | |
63 | m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit", |
|
64 | m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit", | |
64 | action="edit", conditions=dict(method=["GET"], |
|
65 | action="edit", conditions=dict(method=["GET"], | |
65 | function=check_repo)) |
|
66 | function=check_repo)) | |
66 | m.connect("repo", "/repos/{repo_name:.*}", |
|
67 | m.connect("repo", "/repos/{repo_name:.*}", | |
67 | action="show", conditions=dict(method=["GET"], |
|
68 | action="show", conditions=dict(method=["GET"], | |
68 | function=check_repo)) |
|
69 | function=check_repo)) | |
69 | m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}", |
|
70 | m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}", | |
70 | action="show", conditions=dict(method=["GET"], |
|
71 | action="show", conditions=dict(method=["GET"], | |
71 | function=check_repo)) |
|
72 | function=check_repo)) | |
72 | #ajax delete repo perm user |
|
73 | #ajax delete repo perm user | |
73 | m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}", |
|
74 | m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}", | |
74 | action="delete_perm_user", conditions=dict(method=["DELETE"], |
|
75 | action="delete_perm_user", conditions=dict(method=["DELETE"], | |
75 | function=check_repo)) |
|
76 | function=check_repo)) | |
76 | #ajax delete repo perm users_group |
|
77 | #ajax delete repo perm users_group | |
77 | m.connect('delete_repo_users_group', "/repos_delete_users_group/{repo_name:.*}", |
|
78 | m.connect('delete_repo_users_group', "/repos_delete_users_group/{repo_name:.*}", | |
78 | action="delete_perm_users_group", conditions=dict(method=["DELETE"], |
|
79 | action="delete_perm_users_group", conditions=dict(method=["DELETE"], | |
79 | function=check_repo)) |
|
80 | function=check_repo)) | |
80 |
|
81 | |||
81 | #settings actions |
|
82 | #settings actions | |
82 | m.connect('repo_stats', "/repos_stats/{repo_name:.*}", |
|
83 | m.connect('repo_stats', "/repos_stats/{repo_name:.*}", | |
83 | action="repo_stats", conditions=dict(method=["DELETE"], |
|
84 | action="repo_stats", conditions=dict(method=["DELETE"], | |
84 | function=check_repo)) |
|
85 | function=check_repo)) | |
85 | m.connect('repo_cache', "/repos_cache/{repo_name:.*}", |
|
86 | m.connect('repo_cache', "/repos_cache/{repo_name:.*}", | |
86 | action="repo_cache", conditions=dict(method=["DELETE"], |
|
87 | action="repo_cache", conditions=dict(method=["DELETE"], | |
87 | function=check_repo)) |
|
88 | function=check_repo)) | |
88 |
|
89 | |||
89 | #ADMIN USER REST ROUTES |
|
90 | #ADMIN USER REST ROUTES | |
90 | map.resource('user', 'users', controller='admin/users', path_prefix='/_admin') |
|
91 | routes_map.resource('user', 'users', controller='admin/users', path_prefix='/_admin') | |
91 |
|
92 | |||
92 | #ADMIN USER REST ROUTES |
|
93 | #ADMIN USER REST ROUTES | |
93 | map.resource('users_group', 'users_groups', controller='admin/users_groups', path_prefix='/_admin') |
|
94 | routes_map.resource('users_group', 'users_groups', controller='admin/users_groups', path_prefix='/_admin') | |
94 |
|
95 | |||
95 | #ADMIN GROUP REST ROUTES |
|
96 | #ADMIN GROUP REST ROUTES | |
96 | map.resource('group', 'groups', controller='admin/groups', path_prefix='/_admin') |
|
97 | routes_map.resource('group', 'groups', controller='admin/groups', path_prefix='/_admin') | |
97 |
|
98 | |||
98 | #ADMIN PERMISSIONS REST ROUTES |
|
99 | #ADMIN PERMISSIONS REST ROUTES | |
99 | map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin') |
|
100 | routes_map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin') | |
100 |
|
101 | |||
101 | ##ADMIN LDAP SETTINGS |
|
102 | ##ADMIN LDAP SETTINGS | |
102 | map.connect('ldap_settings', '/_admin/ldap', controller='admin/ldap_settings', |
|
103 | routes_map.connect('ldap_settings', '/_admin/ldap', controller='admin/ldap_settings', | |
103 | action='ldap_settings', conditions=dict(method=["POST"])) |
|
104 | action='ldap_settings', conditions=dict(method=["POST"])) | |
104 | map.connect('ldap_home', '/_admin/ldap', controller='admin/ldap_settings',) |
|
105 | routes_map.connect('ldap_home', '/_admin/ldap', controller='admin/ldap_settings',) | |
105 |
|
106 | |||
106 |
|
107 | |||
107 | #ADMIN SETTINGS REST ROUTES |
|
108 | #ADMIN SETTINGS REST ROUTES | |
108 | with map.submapper(path_prefix='/_admin', controller='admin/settings') as m: |
|
109 | with routes_map.submapper(path_prefix='/_admin', controller='admin/settings') as m: | |
109 | m.connect("admin_settings", "/settings", |
|
110 | m.connect("admin_settings", "/settings", | |
110 | action="create", conditions=dict(method=["POST"])) |
|
111 | action="create", conditions=dict(method=["POST"])) | |
111 | m.connect("admin_settings", "/settings", |
|
112 | m.connect("admin_settings", "/settings", | |
112 | action="index", conditions=dict(method=["GET"])) |
|
113 | action="index", conditions=dict(method=["GET"])) | |
113 | m.connect("formatted_admin_settings", "/settings.{format}", |
|
114 | m.connect("formatted_admin_settings", "/settings.{format}", | |
114 | action="index", conditions=dict(method=["GET"])) |
|
115 | action="index", conditions=dict(method=["GET"])) | |
115 | m.connect("admin_new_setting", "/settings/new", |
|
116 | m.connect("admin_new_setting", "/settings/new", | |
116 | action="new", conditions=dict(method=["GET"])) |
|
117 | action="new", conditions=dict(method=["GET"])) | |
117 | m.connect("formatted_admin_new_setting", "/settings/new.{format}", |
|
118 | m.connect("formatted_admin_new_setting", "/settings/new.{format}", | |
118 | action="new", conditions=dict(method=["GET"])) |
|
119 | action="new", conditions=dict(method=["GET"])) | |
119 | m.connect("/settings/{setting_id}", |
|
120 | m.connect("/settings/{setting_id}", | |
120 | action="update", conditions=dict(method=["PUT"])) |
|
121 | action="update", conditions=dict(method=["PUT"])) | |
121 | m.connect("/settings/{setting_id}", |
|
122 | m.connect("/settings/{setting_id}", | |
122 | action="delete", conditions=dict(method=["DELETE"])) |
|
123 | action="delete", conditions=dict(method=["DELETE"])) | |
123 | m.connect("admin_edit_setting", "/settings/{setting_id}/edit", |
|
124 | m.connect("admin_edit_setting", "/settings/{setting_id}/edit", | |
124 | action="edit", conditions=dict(method=["GET"])) |
|
125 | action="edit", conditions=dict(method=["GET"])) | |
125 | m.connect("formatted_admin_edit_setting", "/settings/{setting_id}.{format}/edit", |
|
126 | m.connect("formatted_admin_edit_setting", "/settings/{setting_id}.{format}/edit", | |
126 | action="edit", conditions=dict(method=["GET"])) |
|
127 | action="edit", conditions=dict(method=["GET"])) | |
127 | m.connect("admin_setting", "/settings/{setting_id}", |
|
128 | m.connect("admin_setting", "/settings/{setting_id}", | |
128 | action="show", conditions=dict(method=["GET"])) |
|
129 | action="show", conditions=dict(method=["GET"])) | |
129 | m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", |
|
130 | m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", | |
130 | action="show", conditions=dict(method=["GET"])) |
|
131 | action="show", conditions=dict(method=["GET"])) | |
131 | m.connect("admin_settings_my_account", "/my_account", |
|
132 | m.connect("admin_settings_my_account", "/my_account", | |
132 | action="my_account", conditions=dict(method=["GET"])) |
|
133 | action="my_account", conditions=dict(method=["GET"])) | |
133 | m.connect("admin_settings_my_account_update", "/my_account_update", |
|
134 | m.connect("admin_settings_my_account_update", "/my_account_update", | |
134 | action="my_account_update", conditions=dict(method=["PUT"])) |
|
135 | action="my_account_update", conditions=dict(method=["PUT"])) | |
135 | m.connect("admin_settings_create_repository", "/create_repository", |
|
136 | m.connect("admin_settings_create_repository", "/create_repository", | |
136 | action="create_repository", conditions=dict(method=["GET"])) |
|
137 | action="create_repository", conditions=dict(method=["GET"])) | |
137 |
|
138 | |||
138 | #ADMIN MAIN PAGES |
|
139 | #ADMIN MAIN PAGES | |
139 | with map.submapper(path_prefix='/_admin', controller='admin/admin') as m: |
|
140 | with routes_map.submapper(path_prefix='/_admin', controller='admin/admin') as m: | |
140 | m.connect('admin_home', '', action='index')#main page |
|
141 | m.connect('admin_home', '', action='index')#main page | |
141 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
|
142 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', | |
142 | action='add_repo') |
|
143 | action='add_repo') | |
143 |
|
144 | |||
144 |
|
145 | |||
145 | #USER JOURNAL |
|
146 | #USER JOURNAL | |
146 | map.connect('journal', '/_admin/journal', controller='journal',) |
|
147 | routes_map.connect('journal', '/_admin/journal', controller='journal',) | |
147 | map.connect('toggle_following', '/_admin/toggle_following', controller='journal', |
|
148 | routes_map.connect('toggle_following', '/_admin/toggle_following', controller='journal', | |
148 | action='toggle_following', conditions=dict(method=["POST"])) |
|
149 | action='toggle_following', conditions=dict(method=["POST"])) | |
149 |
|
150 | |||
150 |
|
151 | |||
151 | #SEARCH |
|
152 | #SEARCH | |
152 | map.connect('search', '/_admin/search', controller='search',) |
|
153 | routes_map.connect('search', '/_admin/search', controller='search',) | |
153 | map.connect('search_repo', '/_admin/search/{search_repo:.*}', controller='search') |
|
154 | routes_map.connect('search_repo', '/_admin/search/{search_repo:.*}', controller='search') | |
154 |
|
155 | |||
155 | #LOGIN/LOGOUT/REGISTER/SIGN IN |
|
156 | #LOGIN/LOGOUT/REGISTER/SIGN IN | |
156 | map.connect('login_home', '/_admin/login', controller='login') |
|
157 | routes_map.connect('login_home', '/_admin/login', controller='login') | |
157 | map.connect('logout_home', '/_admin/logout', controller='login', action='logout') |
|
158 | routes_map.connect('logout_home', '/_admin/logout', controller='login', action='logout') | |
158 | map.connect('register', '/_admin/register', controller='login', action='register') |
|
159 | routes_map.connect('register', '/_admin/register', controller='login', action='register') | |
159 | map.connect('reset_password', '/_admin/password_reset', controller='login', action='password_reset') |
|
160 | routes_map.connect('reset_password', '/_admin/password_reset', controller='login', action='password_reset') | |
160 |
|
161 | |||
161 | #FEEDS |
|
162 | #FEEDS | |
162 | map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss', |
|
163 | routes_map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss', | |
163 | controller='feed', action='rss', |
|
164 | controller='feed', action='rss', | |
164 | conditions=dict(function=check_repo)) |
|
165 | conditions=dict(function=check_repo)) | |
165 | map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom', |
|
166 | routes_map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom', | |
166 | controller='feed', action='atom', |
|
167 | controller='feed', action='atom', | |
167 | conditions=dict(function=check_repo)) |
|
168 | conditions=dict(function=check_repo)) | |
168 |
|
169 | |||
169 |
|
170 | |||
170 | #REPOSITORY ROUTES |
|
171 | #REPOSITORY ROUTES | |
171 | map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}', |
|
172 | routes_map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}', | |
172 | controller='changeset', revision='tip', |
|
173 | controller='changeset', revision='tip', | |
173 | conditions=dict(function=check_repo)) |
|
174 | conditions=dict(function=check_repo)) | |
174 | map.connect('raw_changeset_home', '/{repo_name:.*}/raw-changeset/{revision}', |
|
175 | routes_map.connect('raw_changeset_home', '/{repo_name:.*}/raw-changeset/{revision}', | |
175 | controller='changeset', action='raw_changeset', revision='tip', |
|
176 | controller='changeset', action='raw_changeset', revision='tip', | |
176 | conditions=dict(function=check_repo)) |
|
177 | conditions=dict(function=check_repo)) | |
177 | map.connect('summary_home', '/{repo_name:.*}', |
|
178 | routes_map.connect('summary_home', '/{repo_name:.*}', | |
178 | controller='summary', conditions=dict(function=check_repo)) |
|
179 | controller='summary', conditions=dict(function=check_repo)) | |
179 | map.connect('summary_home', '/{repo_name:.*}/summary', |
|
180 | routes_map.connect('summary_home', '/{repo_name:.*}/summary', | |
180 | controller='summary', conditions=dict(function=check_repo)) |
|
181 | controller='summary', conditions=dict(function=check_repo)) | |
181 | map.connect('shortlog_home', '/{repo_name:.*}/shortlog', |
|
182 | routes_map.connect('shortlog_home', '/{repo_name:.*}/shortlog', | |
182 | controller='shortlog', conditions=dict(function=check_repo)) |
|
183 | controller='shortlog', conditions=dict(function=check_repo)) | |
183 | map.connect('branches_home', '/{repo_name:.*}/branches', |
|
184 | routes_map.connect('branches_home', '/{repo_name:.*}/branches', | |
184 | controller='branches', conditions=dict(function=check_repo)) |
|
185 | controller='branches', conditions=dict(function=check_repo)) | |
185 | map.connect('tags_home', '/{repo_name:.*}/tags', |
|
186 | routes_map.connect('tags_home', '/{repo_name:.*}/tags', | |
186 | controller='tags', conditions=dict(function=check_repo)) |
|
187 | controller='tags', conditions=dict(function=check_repo)) | |
187 | map.connect('changelog_home', '/{repo_name:.*}/changelog', |
|
188 | routes_map.connect('changelog_home', '/{repo_name:.*}/changelog', | |
188 | controller='changelog', conditions=dict(function=check_repo)) |
|
189 | controller='changelog', conditions=dict(function=check_repo)) | |
189 | map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}', |
|
190 | routes_map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}', | |
190 | controller='files', revision='tip', f_path='', |
|
191 | controller='files', revision='tip', f_path='', | |
191 | conditions=dict(function=check_repo)) |
|
192 | conditions=dict(function=check_repo)) | |
192 | map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}', |
|
193 | routes_map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}', | |
193 | controller='files', action='diff', revision='tip', f_path='', |
|
194 | controller='files', action='diff', revision='tip', f_path='', | |
194 | conditions=dict(function=check_repo)) |
|
195 | conditions=dict(function=check_repo)) | |
195 | map.connect('files_rawfile_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}', |
|
196 | routes_map.connect('files_rawfile_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}', | |
196 | controller='files', action='rawfile', revision='tip', f_path='', |
|
197 | controller='files', action='rawfile', revision='tip', f_path='', | |
197 | conditions=dict(function=check_repo)) |
|
198 | conditions=dict(function=check_repo)) | |
198 | map.connect('files_raw_home', '/{repo_name:.*}/raw/{revision}/{f_path:.*}', |
|
199 | routes_map.connect('files_raw_home', '/{repo_name:.*}/raw/{revision}/{f_path:.*}', | |
199 | controller='files', action='raw', revision='tip', f_path='', |
|
200 | controller='files', action='raw', revision='tip', f_path='', | |
200 | conditions=dict(function=check_repo)) |
|
201 | conditions=dict(function=check_repo)) | |
201 | map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}', |
|
202 | routes_map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}', | |
202 | controller='files', action='annotate', revision='tip', f_path='', |
|
203 | controller='files', action='annotate', revision='tip', f_path='', | |
203 | conditions=dict(function=check_repo)) |
|
204 | conditions=dict(function=check_repo)) | |
204 | map.connect('files_archive_home', '/{repo_name:.*}/archive/{fname}', |
|
205 | routes_map.connect('files_archive_home', '/{repo_name:.*}/archive/{fname}', | |
205 | controller='files', action='archivefile', |
|
206 | controller='files', action='archivefile', | |
206 | conditions=dict(function=check_repo)) |
|
207 | conditions=dict(function=check_repo)) | |
207 | map.connect('repo_settings_delete', '/{repo_name:.*}/settings', |
|
208 | routes_map.connect('repo_settings_delete', '/{repo_name:.*}/settings', | |
208 | controller='settings', action="delete", |
|
209 | controller='settings', action="delete", | |
209 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
210 | conditions=dict(method=["DELETE"], function=check_repo)) | |
210 | map.connect('repo_settings_update', '/{repo_name:.*}/settings', |
|
211 | routes_map.connect('repo_settings_update', '/{repo_name:.*}/settings', | |
211 | controller='settings', action="update", |
|
212 | controller='settings', action="update", | |
212 | conditions=dict(method=["PUT"], function=check_repo)) |
|
213 | conditions=dict(method=["PUT"], function=check_repo)) | |
213 | map.connect('repo_settings_home', '/{repo_name:.*}/settings', |
|
214 | routes_map.connect('repo_settings_home', '/{repo_name:.*}/settings', | |
214 | controller='settings', action='index', |
|
215 | controller='settings', action='index', | |
215 | conditions=dict(function=check_repo)) |
|
216 | conditions=dict(function=check_repo)) | |
216 |
|
217 | |||
217 | map.connect('repo_fork_create_home', '/{repo_name:.*}/fork', |
|
218 | routes_map.connect('repo_fork_create_home', '/{repo_name:.*}/fork', | |
218 | controller='settings', action='fork_create', |
|
219 | controller='settings', action='fork_create', | |
219 | conditions=dict(function=check_repo, method=["POST"])) |
|
220 | conditions=dict(function=check_repo, method=["POST"])) | |
220 | map.connect('repo_fork_home', '/{repo_name:.*}/fork', |
|
221 | routes_map.connect('repo_fork_home', '/{repo_name:.*}/fork', | |
221 | controller='settings', action='fork', |
|
222 | controller='settings', action='fork', | |
222 | conditions=dict(function=check_repo)) |
|
223 | conditions=dict(function=check_repo)) | |
223 |
|
224 | |||
224 | return map |
|
225 | return routes_map |
General Comments 0
You need to be logged in to leave comments.
Login now