##// END OF EJS Templates
application: re-organize imports for pyramid to prepare code for speedup optimization.
marcink -
r3238:426d07af default
parent child Browse files
Show More
1 NO CONTENT: file renamed from rhodecode/apps/admin/interfaces.py to rhodecode/apps/_base/interfaces.py
@@ -24,7 +24,7 b' import collections'
24 24
25 25 from zope.interface import implementer
26 26
27 from rhodecode.apps.admin.interfaces import IAdminNavigationRegistry
27 from rhodecode.apps._base.interfaces import IAdminNavigationRegistry
28 28 from rhodecode.lib.utils2 import str2bool
29 29 from rhodecode.translation import _
30 30
1 NO CONTENT: file renamed from rhodecode/apps/admin/subscribers.py to rhodecode/apps/_base/subscribers.py
@@ -429,7 +429,7 b' def admin_routes(config):'
429 429
430 430
431 431 def includeme(config):
432 from rhodecode.apps.admin.navigation import includeme as nav_includeme
432 from rhodecode.apps._base.navigation import includeme as nav_includeme
433 433
434 434 # Create admin navigation registry and add it to the pyramid registry.
435 435 nav_includeme(config)
@@ -438,7 +438,5 b' def includeme(config):'
438 438 config.add_route(name='admin_home', pattern=ADMIN_PREFIX)
439 439 config.include(admin_routes, route_prefix=ADMIN_PREFIX)
440 440
441 config.include('.subscribers')
442
443 441 # Scan module for configuration decorators.
444 442 config.scan('.views', ignore='.tests')
@@ -24,7 +24,7 b' from pyramid.httpexceptions import HTTPF'
24 24 from pyramid.view import view_config
25 25
26 26 from rhodecode.apps._base import BaseAppView
27 from rhodecode.apps.admin.navigation import navigation_list
27 from rhodecode.apps._base.navigation import navigation_list
28 28 from rhodecode.lib import helpers as h
29 29 from rhodecode.lib.auth import (
30 30 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
@@ -24,7 +24,7 b' import logging'
24 24 from pyramid.view import view_config
25 25
26 26 from rhodecode.apps._base import BaseAppView
27 from rhodecode.apps.admin.navigation import navigation_list
27 from rhodecode.apps._base.navigation import navigation_list
28 28 from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator)
29 29 from rhodecode.lib.utils import read_opensource_licenses
30 30
@@ -25,7 +25,7 b' import signal'
25 25 from pyramid.view import view_config
26 26
27 27 from rhodecode.apps._base import BaseAppView
28 from rhodecode.apps.admin.navigation import navigation_list
28 from rhodecode.apps._base.navigation import navigation_list
29 29 from rhodecode.lib import system_info
30 30 from rhodecode.lib.auth import (
31 31 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
@@ -24,7 +24,7 b' from pyramid.view import view_config'
24 24 from pyramid.httpexceptions import HTTPFound
25 25
26 26 from rhodecode.apps._base import BaseAppView
27 from rhodecode.apps.admin.navigation import navigation_list
27 from rhodecode.apps._base.navigation import navigation_list
28 28 from rhodecode.lib.auth import (
29 29 LoginRequired, HasPermissionAllDecorator, CSRFRequired)
30 30 from rhodecode.lib.utils2 import safe_int
@@ -33,7 +33,7 b' from pyramid.renderers import render'
33 33 from pyramid.response import Response
34 34
35 35 from rhodecode.apps._base import BaseAppView
36 from rhodecode.apps.admin.navigation import navigation_list
36 from rhodecode.apps._base.navigation import navigation_list
37 37 from rhodecode.apps.svn_support.config_keys import generate_config
38 38 from rhodecode.lib import helpers as h
39 39 from rhodecode.lib.auth import (
@@ -25,7 +25,7 b' from pyramid.view import view_config'
25 25
26 26 import rhodecode
27 27 from rhodecode.apps._base import BaseAppView
28 from rhodecode.apps.admin.navigation import navigation_list
28 from rhodecode.apps._base.navigation import navigation_list
29 29 from rhodecode.lib import helpers as h
30 30 from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator)
31 31 from rhodecode.lib.utils2 import str2bool
@@ -19,7 +19,7 b''
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21
22 from rhodecode.apps.admin.navigation import NavigationRegistry
22 from rhodecode.apps._base.navigation import NavigationRegistry
23 23 from rhodecode.apps._base import ADMIN_PREFIX
24 24 from rhodecode.lib.utils2 import str2bool
25 25
@@ -47,6 +47,9 b' plugin_default_auth_ttl = 30'
47 47 # TODO: When refactoring this think about splitting it up into distinct
48 48 # discover, load and include phases.
49 49 def _discover_plugins(config, entry_point='enterprise.plugins1'):
50 log.debug('authentication: running plugin discovery for entrypoint %s',
51 entry_point)
52
50 53 for ep in iter_entry_points(entry_point):
51 54 plugin_id = '{}{}#{}'.format(
52 55 plugin_prefix, ep.dist.project_name, ep.name)
@@ -73,6 +76,8 b' def _discover_legacy_plugins(config, pre'
73 76 setting in database which are using the specified prefix. Normally 'py:' is
74 77 used for the legacy plugins.
75 78 """
79 log.debug('authentication: running legacy plugin discovery for prefix %s',
80 legacy_plugin_prefix)
76 81 try:
77 82 auth_plugins = SettingsModel().get_setting_by_name('auth_plugins')
78 83 enabled_plugins = auth_plugins.app_settings_value
@@ -23,6 +23,7 b' import sys'
23 23 import logging
24 24 import collections
25 25 import tempfile
26 import time
26 27
27 28 from paste.gzipper import make_gzip_middleware
28 29 import pyramid.events
@@ -78,8 +79,9 b' def make_pyramid_app(global_config, **se'
78 79
79 80 # Allows to use format style "{ENV_NAME}" placeholders in the configuration. It
80 81 # will be replaced by the value of the environment variable "NAME" in this case.
81 environ = {
82 'ENV_{}'.format(key): value for key, value in os.environ.items()}
82 start_time = time.time()
83
84 environ = {'ENV_{}'.format(key): value for key, value in os.environ.items()}
83 85
84 86 global_config = _substitute_values(global_config, environ)
85 87 settings = _substitute_values(settings, environ)
@@ -105,8 +107,8 b' def make_pyramid_app(global_config, **se'
105 107 config.configure_celery(global_config['__file__'])
106 108 # creating the app uses a connection - return it after we are done
107 109 meta.Session.remove()
108
109 log.info('Pyramid app %s created and configured.', pyramid_app)
110 total_time = time.time() - start_time
111 log.info('Pyramid app %s created and configured in %.2fs', pyramid_app, total_time)
110 112 return pyramid_app
111 113
112 114
@@ -215,6 +217,7 b' def includeme_first(config):'
215 217
216 218
217 219 def includeme(config):
220 log.debug('Initializing main includeme from %s', os.path.basename(__file__))
218 221 settings = config.registry.settings
219 222 config.set_request_factory(Request)
220 223
@@ -237,10 +240,13 b' def includeme(config):'
237 240 config.include('rhodecode.authentication')
238 241 config.include('rhodecode.integrations')
239 242
243 config.include('rhodecode.apps._base.navigation')
244 config.include('rhodecode.apps._base.subscribers')
245 config.include('rhodecode.tweens')
246
240 247 # apps
241 248 config.include('rhodecode.apps._base')
242 249 config.include('rhodecode.apps.ops')
243
244 250 config.include('rhodecode.apps.admin')
245 251 config.include('rhodecode.apps.channelstream')
246 252 config.include('rhodecode.apps.login')
@@ -256,13 +262,10 b' def includeme(config):'
256 262 config.include('rhodecode.apps.svn_support')
257 263 config.include('rhodecode.apps.ssh_support')
258 264 config.include('rhodecode.apps.gist')
259
260 265 config.include('rhodecode.apps.debug_style')
261 config.include('rhodecode.tweens')
262 266 config.include('rhodecode.api')
263 267
264 config.add_route(
265 'rhodecode_support', 'https://rhodecode.com/help/', static=True)
268 config.add_route('rhodecode_support', 'https://rhodecode.com/help/', static=True)
266 269
267 270 config.add_translation_dirs('rhodecode:i18n/')
268 271 settings['default_locale_name'] = settings.get('lang', 'en')
@@ -25,9 +25,9 b' import webhelpers.paginate'
25 25
26 26 from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPNotFound
27 27
28 from rhodecode.integrations import integration_type_registry
28 29 from rhodecode.apps._base import BaseAppView
29 from rhodecode.integrations import integration_type_registry
30 from rhodecode.apps.admin.navigation import navigation_list
30 from rhodecode.apps._base.navigation import navigation_list
31 31 from rhodecode.lib.auth import (
32 32 LoginRequired, CSRFRequired, HasPermissionAnyDecorator,
33 33 HasRepoPermissionAnyDecorator, HasRepoGroupPermissionAnyDecorator)
General Comments 0
You need to be logged in to leave comments. Login now