##// END OF EJS Templates
config: initialize routes directly from RootController...
Thomas De Schampheleire -
r6530:69cd0c05 default
parent child Browse files
Show More
@@ -28,7 +28,6 b' from tg.support.converters import asbool'
28 from kallithea.lib.middleware.https_fixup import HttpsFixup
28 from kallithea.lib.middleware.https_fixup import HttpsFixup
29 from kallithea.lib.middleware.simplegit import SimpleGit
29 from kallithea.lib.middleware.simplegit import SimpleGit
30 from kallithea.lib.middleware.simplehg import SimpleHg
30 from kallithea.lib.middleware.simplehg import SimpleHg
31 from kallithea.config.routing import make_map
32 from kallithea.lib.auth import set_available_permissions
31 from kallithea.lib.auth import set_available_permissions
33 from kallithea.lib.db_manage import DbManage
32 from kallithea.lib.db_manage import DbManage
34 from kallithea.lib.utils import load_rcextensions, make_ui, set_app_settings, set_vcs_config, \
33 from kallithea.lib.utils import load_rcextensions, make_ui, set_app_settings, set_vcs_config, \
@@ -119,10 +118,6 b' def setup_configuration(app):'
119 kallithea.CELERY_EAGER = str2bool(config['app_conf'].get('celery.always.eager'))
118 kallithea.CELERY_EAGER = str2bool(config['app_conf'].get('celery.always.eager'))
120 kallithea.CONFIG = config
119 kallithea.CONFIG = config
121
120
122 # Provide routes mapper to the RoutedController
123 root_controller = app.find_controller('root')
124 root_controller.mapper = config['routes.map'] = make_map(config)
125
126 load_rcextensions(root_path=config['here'])
121 load_rcextensions(root_path=config['here'])
127
122
128 # FIXME move test setup code out of here
123 # FIXME move test setup code out of here
@@ -12,20 +12,21 b''
12 # You should have received a copy of the GNU General Public License
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 from tgext.routes import RoutedController
14 from tgext.routes import RoutedController
15 from kallithea.config.routing import make_map
15 from kallithea.lib.base import BaseController
16 from kallithea.lib.base import BaseController
16 from kallithea.controllers.error import ErrorController
17 from kallithea.controllers.error import ErrorController
17
18 from tg import config
18
19
19 # With TurboGears, the RootController is the controller from which all routing
20 # This is the main Kallithea entry point; TurboGears will forward all requests
20 # starts from. It is 'magically' found based on the fact that a controller
21 # to an instance of 'controller.root.RootController' in the configured
21 # 'foo' is expected to have a class name FooController, located in a file
22 # 'application' module (set by app_cfg.py). Requests are forwarded to
22 # foo.py, inside config['paths']['controllers']. The name 'root' for the root
23 # controllers based on the routing mapper that lives in this root instance.
23 # controller is the default name. The dictionary config['paths'] determines the
24 # The mapper is configured using routes defined in routing.py. This use of the
24 # directories where templates, static files and controllers are found. It is
25 # 'mapper' attribute is a feature of tgext.routes, which is activated by
25 # set up in tg.AppConfig based on AppConfig['package'] ('kallithea') and the
26 # inheriting from its RoutedController class.
26 # respective defaults 'templates', 'public' and 'controllers'.
27 # Inherit from RoutedController to allow Kallithea to use regex-based routing.
28 class RootController(RoutedController, BaseController):
27 class RootController(RoutedController, BaseController):
29
28
29 mapper = make_map(config)
30
30 # the following assignment hooks in error handling
31 # the following assignment hooks in error handling
31 error = ErrorController()
32 error = ErrorController()
@@ -8,6 +8,7 b' from routes.util import URLGenerator'
8 from tg import config
8 from tg import config
9
9
10 import pytest
10 import pytest
11 from kallithea.controllers.root import RootController
11 from kallithea.model.user import UserModel
12 from kallithea.model.user import UserModel
12 from kallithea.model.meta import Session
13 from kallithea.model.meta import Session
13 from kallithea.model.db import Setting, User, UserIpMap
14 from kallithea.model.db import Setting, User, UserIpMap
@@ -26,7 +27,7 b' def pytest_configure():'
26 kallithea.tests.base.testapp = loadapp('config:kallithea/tests/test.ini', relative_to=path)
27 kallithea.tests.base.testapp = loadapp('config:kallithea/tests/test.ini', relative_to=path)
27 logging.disable(logging.NOTSET)
28 logging.disable(logging.NOTSET)
28
29
29 kallithea.tests.base.url = URLGenerator(config['routes.map'], kallithea.tests.base.environ)
30 kallithea.tests.base.url = URLGenerator(RootController().mapper, kallithea.tests.base.environ)
30
31
31
32
32 @pytest.fixture
33 @pytest.fixture
General Comments 0
You need to be logged in to leave comments. Login now