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