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