##// END OF EJS Templates
Use repo-scann at latest possible state....
marcink -
r3832:07f8039e beta
parent child Browse files
Show More
@@ -1,119 +1,120 b''
1 1 """Pylons environment configuration"""
2 2
3 3 import os
4 4 import logging
5 5 import rhodecode
6 6
7 7 from mako.lookup import TemplateLookup
8 8 from pylons.configuration import PylonsConfig
9 9 from pylons.error import handle_mako_error
10 10
11 11 # don't remove this import it does magic for celery
12 12 from rhodecode.lib import celerypylons
13 13
14 14 import rhodecode.lib.app_globals as app_globals
15 15
16 16 from rhodecode.config.routing import make_map
17 17
18 18 from rhodecode.lib import helpers
19 19 from rhodecode.lib.auth import set_available_permissions
20 20 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config,\
21 21 load_rcextensions, check_git_version, set_vcs_config
22 22 from rhodecode.lib.utils2 import engine_from_config, str2bool
23 23 from rhodecode.lib.db_manage import DbManage
24 24 from rhodecode.model import init_model
25 25 from rhodecode.model.scm import ScmModel
26 26
27 27 log = logging.getLogger(__name__)
28 28
29 29
30 30 def load_environment(global_conf, app_conf, initial=False):
31 31 """
32 32 Configure the Pylons environment via the ``pylons.config``
33 33 object
34 34 """
35 35 config = PylonsConfig()
36 36
37 37 # Pylons paths
38 38 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
39 39 paths = dict(
40 40 root=root,
41 41 controllers=os.path.join(root, 'controllers'),
42 42 static_files=os.path.join(root, 'public'),
43 43 templates=[os.path.join(root, 'templates')]
44 44 )
45 45
46 46 # Initialize config with the basic options
47 47 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths)
48 48
49 49 # store some globals into rhodecode
50 50 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
51 51 rhodecode.CELERY_EAGER = str2bool(config['app_conf'].get('celery.always.eager'))
52 52
53 53 config['routes.map'] = make_map(config)
54 54 config['pylons.app_globals'] = app_globals.Globals(config)
55 55 config['pylons.h'] = helpers
56 56 rhodecode.CONFIG = config
57 57
58 58 load_rcextensions(root_path=config['here'])
59 59
60 60 # Setup cache object as early as possible
61 61 import pylons
62 62 pylons.cache._push_object(config['pylons.app_globals'].cache)
63 63
64 64 # Create the Mako TemplateLookup, with the default auto-escaping
65 65 config['pylons.app_globals'].mako_lookup = TemplateLookup(
66 66 directories=paths['templates'],
67 67 error_handler=handle_mako_error,
68 68 module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
69 69 input_encoding='utf-8', default_filters=['escape'],
70 70 imports=['from webhelpers.html import escape'])
71 71
72 72 # sets the c attribute access when don't existing attribute are accessed
73 73 config['pylons.strict_tmpl_context'] = True
74 74 test = os.path.split(config['__file__'])[-1] == 'test.ini'
75 75 if test:
76 76 if os.environ.get('TEST_DB'):
77 77 # swap config if we pass enviroment variable
78 78 config['sqlalchemy.db1.url'] = os.environ.get('TEST_DB')
79 79
80 80 from rhodecode.lib.utils import create_test_env, create_test_index
81 81 from rhodecode.tests import TESTS_TMP_PATH
82 82 # set RC_NO_TMP_PATH=1 to disable re-creating the database and
83 83 # test repos
84 84 if not int(os.environ.get('RC_NO_TMP_PATH', 0)):
85 85 create_test_env(TESTS_TMP_PATH, config)
86 86 # set RC_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
87 87 if not int(os.environ.get('RC_WHOOSH_TEST_DISABLE', 0)):
88 88 create_test_index(TESTS_TMP_PATH, config, True)
89 89
90 #check git version
91 check_git_version()
92 90 DbManage.check_waitress()
93 91 # MULTIPLE DB configs
94 92 # Setup the SQLAlchemy database engine
95 93 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
96 94 init_model(sa_engine_db1)
97 95
96 set_available_permissions(config)
98 97 repos_path = make_ui('db').configitems('paths')[0][1]
99 if str2bool(config.get('initial_repo_scan', True)):
100 repo2db_mapper(ScmModel().repo_scan(repos_path),
101 remove_obsolete=False, install_git_hook=False)
102 set_available_permissions(config)
103 98 config['base_path'] = repos_path
104 99 set_rhodecode_config(config)
105 100
106 101 instance_id = rhodecode.CONFIG.get('instance_id')
107 102 if instance_id == '*':
108 103 instance_id = '%s-%s' % (os.uname()[1], os.getpid())
109 104 rhodecode.CONFIG['instance_id'] = instance_id
110 105
111 106 # CONFIGURATION OPTIONS HERE (note: all config options will override
112 107 # any Pylons config options)
113 108
114 109 # store config reference into our module to skip import magic of
115 110 # pylons
116 111 rhodecode.CONFIG.update(config)
112 set_vcs_config(rhodecode.CONFIG)
117 113
118 set_vcs_config(rhodecode.CONFIG)
114 #check git version
115 check_git_version()
116
117 if str2bool(config.get('initial_repo_scan', True)):
118 repo2db_mapper(ScmModel().repo_scan(repos_path),
119 remove_obsolete=False, install_git_hook=False)
119 120 return config
General Comments 0
You need to be logged in to leave comments. Login now