##// END OF EJS Templates
changed dev and tests to postgressql for more error proof setup....
marcink -
r964:84bb5b8b beta
parent child Browse files
Show More
@@ -1,216 +1,217 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # RhodeCode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by RhodeCode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 32 threadpool_max_requests = 6
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = false
36 36
37 37 use = egg:Paste#http
38 38 host = 0.0.0.0
39 39 port = 5000
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 44 static_files = true
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 48 cut_off_limit = 256000
49 49 force_https = false
50 50
51 51 ####################################
52 52 ### CELERY CONFIG ####
53 53 ####################################
54 54 use_celery = false
55 55 broker.host = localhost
56 56 broker.vhost = rabbitmqhost
57 57 broker.port = 5672
58 58 broker.user = rabbitmq
59 59 broker.password = qweqwe
60 60
61 61 celery.imports = rhodecode.lib.celerylib.tasks
62 62
63 63 celery.result.backend = amqp
64 64 celery.result.dburi = amqp://
65 65 celery.result.serialier = json
66 66
67 67 #celery.send.task.error.emails = true
68 68 #celery.amqp.task.result.expires = 18000
69 69
70 70 celeryd.concurrency = 2
71 71 #celeryd.log.file = celeryd.log
72 72 celeryd.log.level = debug
73 73 celeryd.max.tasks.per.child = 3
74 74
75 75 #tasks will never be sent to the queue, but executed locally instead.
76 76 celery.always.eager = false
77 77
78 78 ####################################
79 79 ### BEAKER CACHE ####
80 80 ####################################
81 81 beaker.cache.data_dir=/%(here)s/data/cache/data
82 82 beaker.cache.lock_dir=/%(here)s/data/cache/lock
83 83 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
84 84
85 85 beaker.cache.super_short_term.type=memory
86 86 beaker.cache.super_short_term.expire=10
87 87
88 88 beaker.cache.short_term.type=memory
89 89 beaker.cache.short_term.expire=60
90 90
91 91 beaker.cache.long_term.type=memory
92 92 beaker.cache.long_term.expire=36000
93 93
94 94 beaker.cache.sql_cache_short.type=memory
95 95 beaker.cache.sql_cache_short.expire=10
96 96
97 97 beaker.cache.sql_cache_med.type=memory
98 98 beaker.cache.sql_cache_med.expire=360
99 99
100 100 beaker.cache.sql_cache_long.type=file
101 101 beaker.cache.sql_cache_long.expire=3600
102 102
103 103 ####################################
104 104 ### BEAKER SESSION ####
105 105 ####################################
106 106 ## Type of storage used for the session, current types are
107 107 ## dbm, file, memcached, database, and memory.
108 108 ## The storage uses the Container API
109 109 ##that is also used by the cache system.
110 110 beaker.session.type = file
111 111
112 112 beaker.session.key = rhodecode
113 113 beaker.session.secret = g654dcno0-9873jhgfreyu
114 114 beaker.session.timeout = 36000
115 115
116 116 ##auto save the session to not to use .save()
117 117 beaker.session.auto = False
118 118
119 119 ##true exire at browser close
120 120 #beaker.session.cookie_expires = 3600
121 121
122 122
123 123 ################################################################################
124 124 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
125 125 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
126 126 ## execute malicious code after an exception is raised. ##
127 127 ################################################################################
128 128 #set debug = false
129 129
130 130 ##################################
131 131 ### LOGVIEW CONFIG ###
132 132 ##################################
133 133 logview.sqlalchemy = #faa
134 134 logview.pylons.templating = #bfb
135 135 logview.pylons.util = #eee
136 136
137 137 #########################################################
138 138 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
139 139 #########################################################
140 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
140 #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
141 sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode
141 142 #sqlalchemy.db1.echo = False
142 143 #sqlalchemy.db1.pool_recycle = 3600
143 144 sqlalchemy.convert_unicode = true
144 145
145 146 ################################
146 147 ### LOGGING CONFIGURATION ####
147 148 ################################
148 149 [loggers]
149 150 keys = root, routes, rhodecode, sqlalchemy,beaker,templates
150 151
151 152 [handlers]
152 153 keys = console
153 154
154 155 [formatters]
155 156 keys = generic,color_formatter
156 157
157 158 #############
158 159 ## LOGGERS ##
159 160 #############
160 161 [logger_root]
161 162 level = NOTSET
162 163 handlers = console
163 164
164 165 [logger_routes]
165 166 level = DEBUG
166 167 handlers = console
167 168 qualname = routes.middleware
168 169 # "level = DEBUG" logs the route matched and routing variables.
169 170 propagate = 0
170 171
171 172 [logger_beaker]
172 173 level = ERROR
173 174 handlers = console
174 175 qualname = beaker.container
175 176 propagate = 0
176 177
177 178 [logger_templates]
178 179 level = INFO
179 180 handlers = console
180 181 qualname = pylons.templating
181 182 propagate = 0
182 183
183 184 [logger_rhodecode]
184 185 level = DEBUG
185 186 handlers = console
186 187 qualname = rhodecode
187 188 propagate = 0
188 189
189 190 [logger_sqlalchemy]
190 191 level = ERROR
191 192 handlers = console
192 193 qualname = sqlalchemy.engine
193 194 propagate = 0
194 195
195 196 ##############
196 197 ## HANDLERS ##
197 198 ##############
198 199
199 200 [handler_console]
200 201 class = StreamHandler
201 202 args = (sys.stderr,)
202 203 level = NOTSET
203 204 formatter = color_formatter
204 205
205 206 ################
206 207 ## FORMATTERS ##
207 208 ################
208 209
209 210 [formatter_generic]
210 211 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
211 212 datefmt = %Y-%m-%d %H:%M:%S
212 213
213 214 [formatter_color_formatter]
214 215 class=rhodecode.lib.colored_formatter.ColorFormatter
215 216 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
216 217 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,499 +1,508 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 rhodecode.lib.db_manage
4 4 ~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 6 Database creation, and setup module for RhodeCode. Used for creation
7 7 of database as well as for migration operations
8 8
9 9 :created_on: Apr 10, 2010
10 10 :author: marcink
11 11 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
12 12 :license: GPLv3, see COPYING for more details.
13 13 """
14 14 # This program is free software; you can redistribute it and/or
15 15 # modify it under the terms of the GNU General Public License
16 16 # as published by the Free Software Foundation; version 2
17 17 # of the License or (at your opinion) any later version of the license.
18 18 #
19 19 # This program is distributed in the hope that it will be useful,
20 20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 22 # GNU General Public License for more details.
23 23 #
24 24 # You should have received a copy of the GNU General Public License
25 25 # along with this program; if not, write to the Free Software
26 26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 27 # MA 02110-1301, USA.
28 28
29 29 import os
30 30 import sys
31 31 import uuid
32 32 import logging
33 33 from os.path import dirname as dn, join as jn
34 34
35 35 from rhodecode import __dbversion__
36 36 from rhodecode.model import meta
37 37
38 38 from rhodecode.lib.auth import get_crypt_password
39 39 from rhodecode.lib.utils import ask_ok
40 40 from rhodecode.model import init_model
41 41 from rhodecode.model.db import User, Permission, RhodeCodeUi, RhodeCodeSettings, \
42 42 UserToPerm, DbMigrateVersion
43 43
44 44 from sqlalchemy.engine import create_engine
45 45
46 46 log = logging.getLogger(__name__)
47 47
48 48 class DbManage(object):
49 49 def __init__(self, log_sql, dbconf, root, tests=False):
50 50 self.dbname = dbconf.split('/')[-1]
51 51 self.tests = tests
52 52 self.root = root
53 53 self.dburi = dbconf
54 54 self.log_sql = log_sql
55 55 self.db_exists = False
56 56 self.init_db()
57 57
58 58 def init_db(self):
59 59 engine = create_engine(self.dburi, echo=self.log_sql)
60 60 init_model(engine)
61 61 self.sa = meta.Session()
62 62
63 63 def check_for_db(self, override):
64 64 db_path = jn(self.root, self.dbname)
65 65 if self.dburi.startswith('sqlite'):
66 66 log.info('checking for existing db in %s', db_path)
67 67 if os.path.isfile(db_path):
68 68
69 69 self.db_exists = True
70 70 if not override:
71 71 raise Exception('database already exists')
72 return 'sqlite'
73 if self.dburi.startswith('postgresql'):
74 self.db_exists = True
75 return 'postgresql'
76
72 77
73 78 def create_tables(self, override=False):
74 79 """Create a auth database
75 80 """
76 81
77 self.check_for_db(override)
82 db_type = self.check_for_db(override)
78 83 if self.db_exists:
79 84 log.info("database exist and it's going to be destroyed")
80 85 if self.tests:
81 86 destroy = True
82 87 else:
83 88 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
84 89 if not destroy:
85 90 sys.exit()
86 91 if self.db_exists and destroy:
87 os.remove(jn(self.root, self.dbname))
92 if db_type == 'sqlite':
93 os.remove(jn(self.root, self.dbname))
94 if db_type == 'postgresql':
95 meta.Base.metadata.drop_all()
96
88 97 checkfirst = not override
89 98 meta.Base.metadata.create_all(checkfirst=checkfirst)
90 99 log.info('Created tables for %s', self.dbname)
91 100
92 101
93 102
94 103 def set_db_version(self):
95 104 try:
96 105 ver = DbMigrateVersion()
97 106 ver.version = __dbversion__
98 107 ver.repository_id = 'rhodecode_db_migrations'
99 108 ver.repository_path = 'versions'
100 109 self.sa.add(ver)
101 110 self.sa.commit()
102 111 except:
103 112 self.sa.rollback()
104 113 raise
105 114 log.info('db version set to: %s', __dbversion__)
106 115
107 116
108 117 def upgrade(self):
109 118 """Upgrades given database schema to given revision following
110 119 all needed steps, to perform the upgrade
111 120
112 121 """
113 122
114 123 from rhodecode.lib.dbmigrate.migrate.versioning import api
115 124 from rhodecode.lib.dbmigrate.migrate.exceptions import \
116 125 DatabaseNotControlledError
117 126
118 127 upgrade = ask_ok('You are about to perform database upgrade, make '
119 128 'sure You backed up your database before. '
120 129 'Continue ? [y/n]')
121 130 if not upgrade:
122 131 sys.exit('Nothing done')
123 132
124 133 repository_path = jn(dn(dn(dn(os.path.realpath(__file__)))),
125 134 'rhodecode/lib/dbmigrate')
126 135 db_uri = self.dburi
127 136
128 137 try:
129 138 curr_version = api.db_version(db_uri, repository_path)
130 139 msg = ('Found current database under version'
131 140 ' control with version %s' % curr_version)
132 141
133 142 except (RuntimeError, DatabaseNotControlledError), e:
134 143 curr_version = 1
135 144 msg = ('Current database is not under version control. Setting'
136 145 ' as version %s' % curr_version)
137 146 api.version_control(db_uri, repository_path, curr_version)
138 147
139 148 print (msg)
140 149
141 150 if curr_version == __dbversion__:
142 151 sys.exit('This database is already at the newest version')
143 152
144 153 #======================================================================
145 154 # UPGRADE STEPS
146 155 #======================================================================
147 156 class UpgradeSteps(object):
148 157 """Those steps follow schema versions so for example schema
149 158 for example schema with seq 002 == step_2 and so on.
150 159 """
151 160
152 161 def __init__(self, klass):
153 162 self.klass = klass
154 163
155 164 def step_0(self):
156 165 #step 0 is the schema upgrade, and than follow proper upgrades
157 166 print ('attempting to do database upgrade to version %s' \
158 167 % __dbversion__)
159 168 api.upgrade(db_uri, repository_path, __dbversion__)
160 169 print ('Schema upgrade completed')
161 170
162 171 def step_1(self):
163 172 pass
164 173
165 174 def step_2(self):
166 175 print ('Patching repo paths for newer version of RhodeCode')
167 176 self.klass.fix_repo_paths()
168 177
169 178 print ('Patching default user of RhodeCode')
170 179 self.klass.fix_default_user()
171 180
172 181 log.info('Changing ui settings')
173 182 self.klass.create_ui_settings()
174 183
175 184 def step_3(self):
176 185 print ('Adding additional settings into RhodeCode db')
177 186 self.klass.fix_settings()
178 187
179 188 upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1)
180 189
181 190 #CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE
182 191 for step in upgrade_steps:
183 192 print ('performing upgrade step %s' % step)
184 193 callable = getattr(UpgradeSteps(self), 'step_%s' % step)()
185 194
186 195
187 196
188 197 def fix_repo_paths(self):
189 198 """Fixes a old rhodecode version path into new one without a '*'
190 199 """
191 200
192 201 paths = self.sa.query(RhodeCodeUi)\
193 202 .filter(RhodeCodeUi.ui_key == '/')\
194 203 .scalar()
195 204
196 205 paths.ui_value = paths.ui_value.replace('*', '')
197 206
198 207 try:
199 208 self.sa.add(paths)
200 209 self.sa.commit()
201 210 except:
202 211 self.sa.rollback()
203 212 raise
204 213
205 214 def fix_default_user(self):
206 215 """Fixes a old default user with some 'nicer' default values,
207 216 used mostly for anonymous access
208 217 """
209 218 def_user = self.sa.query(User)\
210 219 .filter(User.username == 'default')\
211 220 .one()
212 221
213 222 def_user.name = 'Anonymous'
214 223 def_user.lastname = 'User'
215 224 def_user.email = 'anonymous@rhodecode.org'
216 225
217 226 try:
218 227 self.sa.add(def_user)
219 228 self.sa.commit()
220 229 except:
221 230 self.sa.rollback()
222 231 raise
223 232
224 233 def fix_settings(self):
225 234 """Fixes rhodecode settings adds ga_code key for google analytics
226 235 """
227 236
228 237 hgsettings3 = RhodeCodeSettings('ga_code', '')
229 238
230 239 try:
231 240 self.sa.add(hgsettings3)
232 241 self.sa.commit()
233 242 except:
234 243 self.sa.rollback()
235 244 raise
236 245
237 246 def admin_prompt(self, second=False):
238 247 if not self.tests:
239 248 import getpass
240 249
241 250
242 251 def get_password():
243 252 password = getpass.getpass('Specify admin password (min 6 chars):')
244 253 confirm = getpass.getpass('Confirm password:')
245 254
246 255 if password != confirm:
247 256 log.error('passwords mismatch')
248 257 return False
249 258 if len(password) < 6:
250 259 log.error('password is to short use at least 6 characters')
251 260 return False
252 261
253 262 return password
254 263
255 264 username = raw_input('Specify admin username:')
256 265
257 266 password = get_password()
258 267 if not password:
259 268 #second try
260 269 password = get_password()
261 270 if not password:
262 271 sys.exit()
263 272
264 273 email = raw_input('Specify admin email:')
265 274 self.create_user(username, password, email, True)
266 275 else:
267 276 log.info('creating admin and regular test users')
268 277 self.create_user('test_admin', 'test12', 'test_admin@mail.com', True)
269 278 self.create_user('test_regular', 'test12', 'test_regular@mail.com', False)
270 279 self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False)
271 280
272 281 def create_ui_settings(self):
273 282 """Creates ui settings, fills out hooks
274 283 and disables dotencode
275 284
276 285 """
277 286 #HOOKS
278 287 hooks1_key = 'changegroup.update'
279 288 hooks1_ = self.sa.query(RhodeCodeUi)\
280 289 .filter(RhodeCodeUi.ui_key == hooks1_key).scalar()
281 290
282 291 hooks1 = RhodeCodeUi() if hooks1_ is None else hooks1_
283 292 hooks1.ui_section = 'hooks'
284 293 hooks1.ui_key = hooks1_key
285 294 hooks1.ui_value = 'hg update >&2'
286 295 hooks1.ui_active = False
287 296
288 297 hooks2_key = 'changegroup.repo_size'
289 298 hooks2_ = self.sa.query(RhodeCodeUi)\
290 299 .filter(RhodeCodeUi.ui_key == hooks2_key).scalar()
291 300
292 301 hooks2 = RhodeCodeUi() if hooks2_ is None else hooks2_
293 302 hooks2.ui_section = 'hooks'
294 303 hooks2.ui_key = hooks2_key
295 304 hooks2.ui_value = 'python:rhodecode.lib.hooks.repo_size'
296 305
297 306 hooks3 = RhodeCodeUi()
298 307 hooks3.ui_section = 'hooks'
299 308 hooks3.ui_key = 'pretxnchangegroup.push_logger'
300 309 hooks3.ui_value = 'python:rhodecode.lib.hooks.log_push_action'
301 310
302 311 hooks4 = RhodeCodeUi()
303 312 hooks4.ui_section = 'hooks'
304 313 hooks4.ui_key = 'preoutgoing.pull_logger'
305 314 hooks4.ui_value = 'python:rhodecode.lib.hooks.log_pull_action'
306 315
307 316 #For mercurial 1.7 set backward comapatibility with format
308 317 dotencode_disable = RhodeCodeUi()
309 318 dotencode_disable.ui_section = 'format'
310 319 dotencode_disable.ui_key = 'dotencode'
311 320 dotencode_disable.ui_value = 'false'
312 321
313 322 try:
314 323 self.sa.add(hooks1)
315 324 self.sa.add(hooks2)
316 325 self.sa.add(hooks3)
317 326 self.sa.add(hooks4)
318 327 self.sa.add(dotencode_disable)
319 328 self.sa.commit()
320 329 except:
321 330 self.sa.rollback()
322 331 raise
323 332
324 333
325 334 def create_ldap_options(self):
326 335 """Creates ldap settings"""
327 336
328 337 try:
329 338 for k in ['ldap_active', 'ldap_host', 'ldap_port', 'ldap_ldaps',
330 339 'ldap_dn_user', 'ldap_dn_pass', 'ldap_base_dn']:
331 340
332 341 setting = RhodeCodeSettings(k, '')
333 342 self.sa.add(setting)
334 343 self.sa.commit()
335 344 except:
336 345 self.sa.rollback()
337 346 raise
338 347
339 348 def config_prompt(self, test_repo_path=''):
340 349 log.info('Setting up repositories config')
341 350
342 351 if not self.tests and not test_repo_path:
343 352 path = raw_input('Specify valid full path to your repositories'
344 353 ' you can change this later in application settings:')
345 354 else:
346 355 path = test_repo_path
347 356
348 357 if not os.path.isdir(path):
349 358 log.error('You entered wrong path: %s', path)
350 359 sys.exit()
351 360
352 361 self.create_ui_settings()
353 362
354 363 #HG UI OPTIONS
355 364 web1 = RhodeCodeUi()
356 365 web1.ui_section = 'web'
357 366 web1.ui_key = 'push_ssl'
358 367 web1.ui_value = 'false'
359 368
360 369 web2 = RhodeCodeUi()
361 370 web2.ui_section = 'web'
362 371 web2.ui_key = 'allow_archive'
363 372 web2.ui_value = 'gz zip bz2'
364 373
365 374 web3 = RhodeCodeUi()
366 375 web3.ui_section = 'web'
367 376 web3.ui_key = 'allow_push'
368 377 web3.ui_value = '*'
369 378
370 379 web4 = RhodeCodeUi()
371 380 web4.ui_section = 'web'
372 381 web4.ui_key = 'baseurl'
373 382 web4.ui_value = '/'
374 383
375 384 paths = RhodeCodeUi()
376 385 paths.ui_section = 'paths'
377 386 paths.ui_key = '/'
378 387 paths.ui_value = path
379 388
380 389
381 390 hgsettings1 = RhodeCodeSettings('realm', 'RhodeCode authentication')
382 391 hgsettings2 = RhodeCodeSettings('title', 'RhodeCode')
383 392 hgsettings3 = RhodeCodeSettings('ga_code', '')
384 393
385 394
386 395 try:
387 396 self.sa.add(web1)
388 397 self.sa.add(web2)
389 398 self.sa.add(web3)
390 399 self.sa.add(web4)
391 400 self.sa.add(paths)
392 401 self.sa.add(hgsettings1)
393 402 self.sa.add(hgsettings2)
394 403 self.sa.add(hgsettings3)
395 404
396 405 self.sa.commit()
397 406 except:
398 407 self.sa.rollback()
399 408 raise
400 409
401 410 self.create_ldap_options()
402 411
403 412 log.info('created ui config')
404 413
405 414 def create_user(self, username, password, email='', admin=False):
406 415 log.info('creating administrator user %s', username)
407 416 new_user = User()
408 417 new_user.username = username
409 418 new_user.password = get_crypt_password(password)
410 419 new_user.name = 'RhodeCode'
411 420 new_user.lastname = 'Admin'
412 421 new_user.email = email
413 422 new_user.admin = admin
414 423 new_user.active = True
415 424
416 425 try:
417 426 self.sa.add(new_user)
418 427 self.sa.commit()
419 428 except:
420 429 self.sa.rollback()
421 430 raise
422 431
423 432 def create_default_user(self):
424 433 log.info('creating default user')
425 434 #create default user for handling default permissions.
426 435 def_user = User()
427 436 def_user.username = 'default'
428 437 def_user.password = get_crypt_password(str(uuid.uuid1())[:8])
429 438 def_user.name = 'Anonymous'
430 439 def_user.lastname = 'User'
431 440 def_user.email = 'anonymous@rhodecode.org'
432 441 def_user.admin = False
433 442 def_user.active = False
434 443 try:
435 444 self.sa.add(def_user)
436 445 self.sa.commit()
437 446 except:
438 447 self.sa.rollback()
439 448 raise
440 449
441 450 def create_permissions(self):
442 451 #module.(access|create|change|delete)_[name]
443 452 #module.(read|write|owner)
444 453 perms = [('repository.none', 'Repository no access'),
445 454 ('repository.read', 'Repository read access'),
446 455 ('repository.write', 'Repository write access'),
447 456 ('repository.admin', 'Repository admin access'),
448 457 ('hg.admin', 'Hg Administrator'),
449 458 ('hg.create.repository', 'Repository create'),
450 459 ('hg.create.none', 'Repository creation disabled'),
451 460 ('hg.register.none', 'Register disabled'),
452 461 ('hg.register.manual_activate', 'Register new user with rhodecode without manual activation'),
453 462 ('hg.register.auto_activate', 'Register new user with rhodecode without auto activation'),
454 463 ]
455 464
456 465 for p in perms:
457 466 new_perm = Permission()
458 467 new_perm.permission_name = p[0]
459 468 new_perm.permission_longname = p[1]
460 469 try:
461 470 self.sa.add(new_perm)
462 471 self.sa.commit()
463 472 except:
464 473 self.sa.rollback()
465 474 raise
466 475
467 476 def populate_default_permissions(self):
468 477 log.info('creating default user permissions')
469 478
470 479 default_user = self.sa.query(User)\
471 480 .filter(User.username == 'default').scalar()
472 481
473 482 reg_perm = UserToPerm()
474 483 reg_perm.user = default_user
475 484 reg_perm.permission = self.sa.query(Permission)\
476 485 .filter(Permission.permission_name == 'hg.register.manual_activate')\
477 486 .scalar()
478 487
479 488 create_repo_perm = UserToPerm()
480 489 create_repo_perm.user = default_user
481 490 create_repo_perm.permission = self.sa.query(Permission)\
482 491 .filter(Permission.permission_name == 'hg.create.repository')\
483 492 .scalar()
484 493
485 494 default_repo_perm = UserToPerm()
486 495 default_repo_perm.user = default_user
487 496 default_repo_perm.permission = self.sa.query(Permission)\
488 497 .filter(Permission.permission_name == 'repository.read')\
489 498 .scalar()
490 499
491 500 try:
492 501 self.sa.add(reg_perm)
493 502 self.sa.add(create_repo_perm)
494 503 self.sa.add(default_repo_perm)
495 504 self.sa.commit()
496 505 except:
497 506 self.sa.rollback()
498 507 raise
499 508
@@ -1,203 +1,204 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # rhodecode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by rhodecode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25
26 26 [server:main]
27 27 ##nr of threads to spawn
28 28 threadpool_workers = 5
29 29
30 30 ##max request before thread respawn
31 31 threadpool_max_requests = 2
32 32
33 33 ##option to use threads of process
34 34 use_threadpool = true
35 35
36 36 use = egg:Paste#http
37 37 host = 127.0.0.1
38 38 port = 5000
39 39
40 40 [app:main]
41 41 use = egg:rhodecode
42 42 full_stack = true
43 43 static_files = true
44 44 lang=en
45 45 cache_dir = %(here)s/data
46 46 index_dir = /tmp/index
47 47 cut_off_limit = 256000
48 48 force_https = false
49 49
50 50 ####################################
51 51 ### CELERY CONFIG ####
52 52 ####################################
53 53 use_celery = false
54 54 broker.host = localhost
55 55 broker.vhost = rabbitmqhost
56 56 broker.port = 5672
57 57 broker.user = rabbitmq
58 58 broker.password = qweqwe
59 59
60 60 celery.imports = rhodecode.lib.celerylib.tasks
61 61
62 62 celery.result.backend = amqp
63 63 celery.result.dburi = amqp://
64 64 celery.result.serialier = json
65 65
66 66 #celery.send.task.error.emails = true
67 67 #celery.amqp.task.result.expires = 18000
68 68
69 69 celeryd.concurrency = 2
70 70 #celeryd.log.file = celeryd.log
71 71 celeryd.log.level = debug
72 72 celeryd.max.tasks.per.child = 3
73 73
74 74 #tasks will never be sent to the queue, but executed locally instead.
75 75 celery.always.eager = false
76 76
77 77 ####################################
78 78 ### BEAKER CACHE ####
79 79 ####################################
80 80 beaker.cache.data_dir=/%(here)s/data/cache/data
81 81 beaker.cache.lock_dir=/%(here)s/data/cache/lock
82 82 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
83 83
84 84 beaker.cache.super_short_term.type=memory
85 85 beaker.cache.super_short_term.expire=10
86 86
87 87 beaker.cache.short_term.type=memory
88 88 beaker.cache.short_term.expire=60
89 89
90 90 beaker.cache.long_term.type=memory
91 91 beaker.cache.long_term.expire=36000
92 92
93 93
94 94 beaker.cache.sql_cache_short.type=memory
95 95 beaker.cache.sql_cache_short.expire=5
96 96
97 97 beaker.cache.sql_cache_med.type=memory
98 98 beaker.cache.sql_cache_med.expire=360
99 99
100 100 beaker.cache.sql_cache_long.type=file
101 101 beaker.cache.sql_cache_long.expire=3600
102 102
103 103 ####################################
104 104 ### BEAKER SESSION ####
105 105 ####################################
106 106 ## Type of storage used for the session, current types are
107 107 ## dbm, file, memcached, database, and memory.
108 108 ## The storage uses the Container API
109 109 ##that is also used by the cache system.
110 110 beaker.session.type = file
111 111
112 112 beaker.session.key = rhodecode
113 113 beaker.session.secret = g654dcno0-9873jhgfreyu
114 114 beaker.session.timeout = 36000
115 115
116 116 ##auto save the session to not to use .save()
117 117 beaker.session.auto = False
118 118
119 119 ##true exire at browser close
120 120 #beaker.session.cookie_expires = 3600
121 121
122 122
123 123 ################################################################################
124 124 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
125 125 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
126 126 ## execute malicious code after an exception is raised. ##
127 127 ################################################################################
128 128 #set debug = false
129 129
130 130 ##################################
131 131 ### LOGVIEW CONFIG ###
132 132 ##################################
133 133 logview.sqlalchemy = #faa
134 134 logview.pylons.templating = #bfb
135 135 logview.pylons.util = #eee
136 136
137 137 #########################################################
138 138 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
139 139 #########################################################
140 sqlalchemy.db1.url = sqlite:///%(here)s/test.db
140 #sqlalchemy.db1.url = sqlite:///%(here)s/test.db
141 sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode_tests
141 142 #sqlalchemy.db1.echo = False
142 143 #sqlalchemy.db1.pool_recycle = 3600
143 144 sqlalchemy.convert_unicode = true
144 145
145 146 ################################
146 147 ### LOGGING CONFIGURATION ####
147 148 ################################
148 149 [loggers]
149 150 keys = root, routes, rhodecode, sqlalchemy
150 151
151 152 [handlers]
152 153 keys = console
153 154
154 155 [formatters]
155 156 keys = generic,color_formatter
156 157
157 158 #############
158 159 ## LOGGERS ##
159 160 #############
160 161 [logger_root]
161 162 level = ERROR
162 163 handlers = console
163 164
164 165 [logger_routes]
165 166 level = ERROR
166 167 handlers = console
167 168 qualname = routes.middleware
168 169 # "level = DEBUG" logs the route matched and routing variables.
169 170
170 171 [logger_rhodecode]
171 172 level = ERROR
172 173 handlers = console
173 174 qualname = rhodecode
174 175 propagate = 0
175 176
176 177 [logger_sqlalchemy]
177 178 level = ERROR
178 179 handlers = console
179 180 qualname = sqlalchemy.engine
180 181 propagate = 0
181 182
182 183 ##############
183 184 ## HANDLERS ##
184 185 ##############
185 186
186 187 [handler_console]
187 188 class = StreamHandler
188 189 args = (sys.stderr,)
189 190 level = NOTSET
190 191 formatter = color_formatter
191 192
192 193 ################
193 194 ## FORMATTERS ##
194 195 ################
195 196
196 197 [formatter_generic]
197 198 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
198 199 datefmt = %Y-%m-%d %H:%M:%S
199 200
200 201 [formatter_color_formatter]
201 202 class=rhodecode.lib.colored_formatter.ColorFormatter
202 203 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
203 204 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now