##// END OF EJS Templates
added password validation, second try on paster setup-app,...
marcink -
r597:53128b6b rhodecode-0.0.1.0.0rc4 default
parent child Browse files
Show More
@@ -1,171 +1,172 b''
1 ################################################################################
1 ################################################################################
2 ################################################################################
2 ################################################################################
3 # rhodecode - Pylons environment configuration #
3 # rhodecode - Pylons environment configuration #
4 # #
4 # #
5 # The %(here)s variable will be replaced with the parent directory of this file#
5 # The %(here)s variable will be replaced with the parent directory of this file#
6 ################################################################################
6 ################################################################################
7
7
8 [DEFAULT]
8 [DEFAULT]
9 debug = true
9 debug = true
10 ################################################################################
10 ################################################################################
11 ## Uncomment and replace with the address which should receive ##
11 ## Uncomment and replace with the address which should receive ##
12 ## any error reports after application crash ##
12 ## any error reports after application crash ##
13 ## Additionally those settings will be used by rhodecode mailing system ##
13 ## Additionally those settings will be used by rhodecode mailing system ##
14 ################################################################################
14 ################################################################################
15 #email_to = admin@localhost
15 #email_to = admin@localhost
16 #error_email_from = paste_error@localhost
16 #error_email_from = paste_error@localhost
17 #app_email_from = rhodecode-noreply@localhost
17 #app_email_from = rhodecode-noreply@localhost
18 #error_message =
18 #error_message =
19
19
20 #smtp_server = mail.server.com
20 #smtp_server = mail.server.com
21 #smtp_username =
21 #smtp_username =
22 #smtp_password =
22 #smtp_password =
23 #smtp_port =
23 #smtp_port =
24 #smtp_use_tls =
24 #smtp_use_tls =
25
25
26 [server:main]
26 [server:main]
27 ##nr of threads to spawn
27 ##nr of threads to spawn
28 threadpool_workers = 5
28 threadpool_workers = 5
29
29
30 ##max request before
30 ##max request before
31 threadpool_max_requests = 6
31 threadpool_max_requests = 6
32
32
33 ##option to use threads of process
33 ##option to use threads of process
34 use_threadpool = false
34 use_threadpool = false
35
35
36 use = egg:Paste#http
36 use = egg:Paste#http
37 host = 127.0.0.1
37 host = 127.0.0.1
38 port = 5000
38 port = 5000
39
39
40 [app:main]
40 [app:main]
41 use = egg:rhodecode
41 use = egg:rhodecode
42 full_stack = true
42 full_stack = true
43 static_files = true
43 static_files = true
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46
46
47 ####################################
47 ####################################
48 ### BEAKER CACHE ####
48 ### BEAKER CACHE ####
49 ####################################
49 ####################################
50 beaker.cache.data_dir=/%(here)s/data/cache/data
50 beaker.cache.data_dir=/%(here)s/data/cache/data
51 beaker.cache.lock_dir=/%(here)s/data/cache/lock
51 beaker.cache.lock_dir=/%(here)s/data/cache/lock
52 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
52 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
53 beaker.cache.long_term.type=memory
54 beaker.cache.long_term.expire=36000
55
53
56 beaker.cache.short_term.type=memory
54 beaker.cache.super_short_term.type=memory
57 beaker.cache.short_term.expire=60
55 beaker.cache.super_short_term.expire=10
56
57 beaker.cache.short_term.type=memory
58 beaker.cache.short_term.expire=60
58
59
59 beaker.cache.super_short_term.type=memory
60 beaker.cache.long_term.type=memory
60 beaker.cache.super_short_term.expire=10
61 beaker.cache.long_term.expire=36000
61
62
62 beaker.cache.sql_cache_short.type=memory
63 beaker.cache.sql_cache_short.type=memory
63 beaker.cache.sql_cache_short.expire=5
64 beaker.cache.sql_cache_short.expire=5
64
65
65 beaker.cache.sql_cache_med.type=memory
66 beaker.cache.sql_cache_med.type=memory
66 beaker.cache.sql_cache_med.expire=360
67 beaker.cache.sql_cache_med.expire=360
67
68
68 beaker.cache.sql_cache_long.type=file
69 beaker.cache.sql_cache_long.type=file
69 beaker.cache.sql_cache_long.expire=3600
70 beaker.cache.sql_cache_long.expire=3600
70
71
71 ####################################
72 ####################################
72 ### BEAKER SESSION ####
73 ### BEAKER SESSION ####
73 ####################################
74 ####################################
74 ## Type of storage used for the session, current types are
75 ## Type of storage used for the session, current types are
75 ## "dbm", "file", "memcached", "database", and "memory".
76 ## "dbm", "file", "memcached", "database", and "memory".
76 ## The storage uses the Container API
77 ## The storage uses the Container API
77 ##that is also used by the cache system.
78 ##that is also used by the cache system.
78 beaker.session.type = file
79 beaker.session.type = file
79
80
80 beaker.session.key = rhodecode
81 beaker.session.key = rhodecode
81 beaker.session.secret = g654dcno0-9873jhgfreyu
82 beaker.session.secret = g654dcno0-9873jhgfreyu
82 beaker.session.timeout = 36000
83 beaker.session.timeout = 36000
83
84
84 ##auto save the session to not to use .save()
85 ##auto save the session to not to use .save()
85 beaker.session.auto = False
86 beaker.session.auto = False
86
87
87 ##true exire at browser close
88 ##true exire at browser close
88 #beaker.session.cookie_expires = 3600
89 #beaker.session.cookie_expires = 3600
89
90
90
91
91 ################################################################################
92 ################################################################################
92 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
93 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
93 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
94 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
94 ## execute malicious code after an exception is raised. ##
95 ## execute malicious code after an exception is raised. ##
95 ################################################################################
96 ################################################################################
96 #set debug = false
97 #set debug = false
97
98
98 ##################################
99 ##################################
99 ### LOGVIEW CONFIG ###
100 ### LOGVIEW CONFIG ###
100 ##################################
101 ##################################
101 logview.sqlalchemy = #faa
102 logview.sqlalchemy = #faa
102 logview.pylons.templating = #bfb
103 logview.pylons.templating = #bfb
103 logview.pylons.util = #eee
104 logview.pylons.util = #eee
104
105
105 #########################################################
106 #########################################################
106 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
107 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
107 #########################################################
108 #########################################################
108 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
109 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
109 #sqlalchemy.db1.echo = False
110 #sqlalchemy.db1.echo = False
110 #sqlalchemy.db1.pool_recycle = 3600
111 #sqlalchemy.db1.pool_recycle = 3600
111 sqlalchemy.convert_unicode = true
112 sqlalchemy.convert_unicode = true
112
113
113 ################################
114 ################################
114 ### LOGGING CONFIGURATION ####
115 ### LOGGING CONFIGURATION ####
115 ################################
116 ################################
116 [loggers]
117 [loggers]
117 keys = root, routes, rhodecode, sqlalchemy
118 keys = root, routes, rhodecode, sqlalchemy
118
119
119 [handlers]
120 [handlers]
120 keys = console
121 keys = console
121
122
122 [formatters]
123 [formatters]
123 keys = generic,color_formatter
124 keys = generic,color_formatter
124
125
125 #############
126 #############
126 ## LOGGERS ##
127 ## LOGGERS ##
127 #############
128 #############
128 [logger_root]
129 [logger_root]
129 level = NOTSET
130 level = NOTSET
130 handlers = console
131 handlers = console
131
132
132 [logger_routes]
133 [logger_routes]
133 level = DEBUG
134 level = DEBUG
134 handlers = console
135 handlers = console
135 qualname = routes.middleware
136 qualname = routes.middleware
136 # "level = DEBUG" logs the route matched and routing variables.
137 # "level = DEBUG" logs the route matched and routing variables.
137
138
138 [logger_rhodecode]
139 [logger_rhodecode]
139 level = DEBUG
140 level = DEBUG
140 handlers = console
141 handlers = console
141 qualname = rhodecode
142 qualname = rhodecode
142 propagate = 0
143 propagate = 0
143
144
144 [logger_sqlalchemy]
145 [logger_sqlalchemy]
145 level = ERROR
146 level = ERROR
146 handlers = console
147 handlers = console
147 qualname = sqlalchemy.engine
148 qualname = sqlalchemy.engine
148 propagate = 0
149 propagate = 0
149
150
150 ##############
151 ##############
151 ## HANDLERS ##
152 ## HANDLERS ##
152 ##############
153 ##############
153
154
154 [handler_console]
155 [handler_console]
155 class = StreamHandler
156 class = StreamHandler
156 args = (sys.stderr,)
157 args = (sys.stderr,)
157 level = NOTSET
158 level = NOTSET
158 formatter = color_formatter
159 formatter = color_formatter
159
160
160 ################
161 ################
161 ## FORMATTERS ##
162 ## FORMATTERS ##
162 ################
163 ################
163
164
164 [formatter_generic]
165 [formatter_generic]
165 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
166 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
166 datefmt = %Y-%m-%d %H:%M:%S
167 datefmt = %Y-%m-%d %H:%M:%S
167
168
168 [formatter_color_formatter]
169 [formatter_color_formatter]
169 class=rhodecode.lib.colored_formatter.ColorFormatter
170 class=rhodecode.lib.colored_formatter.ColorFormatter
170 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
171 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
171 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
172 datefmt = %Y-%m-%d %H:%M:%S
@@ -1,20 +1,23 b''
1 .. _changelog:
1 .. _changelog:
2
2
3 Changelog
3 Changelog
4 =========
4 =========
5
5
6 1.0.0rc4 (**2010-10-12**)
6 1.0.0rc4 (**2010-10-12**)
7
7
8 - fixed python2.5 missing simplejson imports (thanks to Jens BΓ€ckman)
8 - fixed python2.5 missing simplejson imports (thanks to Jens BΓ€ckman)
9 - removed cache_manager settings from sqlalchemy meta
9 - removed cache_manager settings from sqlalchemy meta
10 - added sqlalchemy cache settings to ini files
10 - added sqlalchemy cache settings to ini files
11 - validated password length and added second try of failure on paster setup-app
12 - fixed setup database destroy prompt even when there was no db
13
11
14
12 1.0.0rc3 (**2010-10-11**)
15 1.0.0rc3 (**2010-10-11**)
13
16
14 - fixed i18n during installation.
17 - fixed i18n during installation.
15
18
16 1.0.0rc2 (**2010-10-11**)
19 1.0.0rc2 (**2010-10-11**)
17
20
18 - Disabled dirsize in file browser, it's causing nasty bug when dir renames
21 - Disabled dirsize in file browser, it's causing nasty bug when dir renames
19 occure. After vcs is fixed it'll be put back again.
22 occure. After vcs is fixed it'll be put back again.
20 - templating/css rewrites, optimized css.
23 - templating/css rewrites, optimized css.
@@ -1,129 +1,129 b''
1 .. _setup:
1 .. _setup:
2
2
3 Setup
3 Setup
4 =====
4 =====
5
5
6
6
7 Setting up the application
7 Setting up the application
8 --------------------------
8 --------------------------
9
9
10 ::
10 ::
11
11
12 paster make-config RhodeCode production.ini
12 paster make-config RhodeCode production.ini
13
13
14 - This will create `production.ini` config inside the directory
14 - This will create `production.ini` config inside the directory
15 this config contain various settings for rhodecode, e.g port, email settings
15 this config contain various settings for rhodecode, e.g port, email settings
16 static files, cache and logging.
16 static files, cache and logging.
17
17
18 ::
18 ::
19
19
20 paster setup-app production.ini`
20 paster setup-app production.ini
21
21
22 - This command will create all needed tables and an admin account.
22 - This command will create all needed tables and an admin account.
23 When asked for a path You can either use a new location of one with already
23 When asked for a path You can either use a new location of one with already
24 existing ones. RhodeCode will simply add all new found repositories to
24 existing ones. RhodeCode will simply add all new found repositories to
25 it's database. Also make sure You specify correct path to repositories.
25 it's database. Also make sure You specify correct path to repositories.
26 - Remember that the given path for mercurial_ repositories must be write
26 - Remember that the given path for mercurial_ repositories must be write
27 accessible for the application. It's very important since RhodeCode web interface
27 accessible for the application. It's very important since RhodeCode web interface
28 will work even without such an access but, when trying to do a push it'll
28 will work even without such an access but, when trying to do a push it'll
29 eventually fail with permission denied errors.
29 eventually fail with permission denied errors.
30 - Run
30 - Run
31
31
32 ::
32 ::
33
33
34 paster serve production.ini
34 paster serve production.ini
35
35
36 - This command runs the rhodecode server the app should be available at the
36 - This command runs the rhodecode server the app should be available at the
37 127.0.0.1:5000. This ip and port is configurable via the production.ini
37 127.0.0.1:5000. This ip and port is configurable via the production.ini
38 file created in previous step
38 file created in previous step
39 - Use admin account you created to login.
39 - Use admin account you created to login.
40 - Default permissions on each repository is read, and owner is admin. So
40 - Default permissions on each repository is read, and owner is admin. So
41 remember to update these if needed.
41 remember to update these if needed.
42
42
43
43
44 Setting up Whoosh
44 Setting up Whoosh
45 -----------------
45 -----------------
46
46
47 - For full text search You can either put crontab entry for
47 - For full text search You can either put crontab entry for
48
48
49 ::
49 ::
50
50
51 python /var/www/rhodecode/<rhodecode_installation_path>/lib/indexers/daemon.py incremental <put_here_path_to_repos>
51 python /var/www/rhodecode/<rhodecode_installation_path>/lib/indexers/daemon.py incremental <put_here_path_to_repos>
52
52
53 When using incremental mode whoosh will check last modification date of each file
53 When using incremental mode whoosh will check last modification date of each file
54 and add it to reindex if newer file is available. Also indexing daemon checks
54 and add it to reindex if newer file is available. Also indexing daemon checks
55 for removed files and removes them from index. Sometime You might want to rebuild
55 for removed files and removes them from index. Sometime You might want to rebuild
56 index from scrach, in admin pannel You can check `build from scratch` flag
56 index from scrach, in admin pannel You can check `build from scratch` flag
57 and in standalone daemon You can pass `full` instead on incremental to build
57 and in standalone daemon You can pass `full` instead on incremental to build
58 remove previos index and build new one.
58 remove previos index and build new one.
59
59
60 Nginx virtual host example
60 Nginx virtual host example
61 --------------------------
61 --------------------------
62
62
63 Sample config for nginx::
63 Sample config for nginx::
64
64
65 server {
65 server {
66 listen 80;
66 listen 80;
67 server_name hg.myserver.com;
67 server_name hg.myserver.com;
68 access_log /var/log/nginx/rhodecode.access.log;
68 access_log /var/log/nginx/rhodecode.access.log;
69 error_log /var/log/nginx/rhodecode.error.log;
69 error_log /var/log/nginx/rhodecode.error.log;
70 location / {
70 location / {
71 root /var/www/rhodecode/rhodecode/public/;
71 root /var/www/rhodecode/rhodecode/public/;
72 if (!-f $request_filename){
72 if (!-f $request_filename){
73 proxy_pass http://127.0.0.1:5000;
73 proxy_pass http://127.0.0.1:5000;
74 }
74 }
75 #this is important for https !!!
75 #this is important for https !!!
76 proxy_set_header X-Url-Scheme $scheme;
76 proxy_set_header X-Url-Scheme $scheme;
77 include /etc/nginx/proxy.conf;
77 include /etc/nginx/proxy.conf;
78 }
78 }
79 }
79 }
80
80
81 Here's the proxy.conf. It's tuned so it'll not timeout on long
81 Here's the proxy.conf. It's tuned so it'll not timeout on long
82 pushes and also on large pushes::
82 pushes and also on large pushes::
83
83
84 proxy_redirect off;
84 proxy_redirect off;
85 proxy_set_header Host $host;
85 proxy_set_header Host $host;
86 proxy_set_header X-Host $http_host;
86 proxy_set_header X-Host $http_host;
87 proxy_set_header X-Real-IP $remote_addr;
87 proxy_set_header X-Real-IP $remote_addr;
88 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
88 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
89 proxy_set_header Proxy-host $proxy_host;
89 proxy_set_header Proxy-host $proxy_host;
90 client_max_body_size 400m;
90 client_max_body_size 400m;
91 client_body_buffer_size 128k;
91 client_body_buffer_size 128k;
92 proxy_buffering off;
92 proxy_buffering off;
93 proxy_connect_timeout 3600;
93 proxy_connect_timeout 3600;
94 proxy_send_timeout 3600;
94 proxy_send_timeout 3600;
95 proxy_read_timeout 3600;
95 proxy_read_timeout 3600;
96 proxy_buffer_size 8k;
96 proxy_buffer_size 8k;
97 proxy_buffers 8 32k;
97 proxy_buffers 8 32k;
98 proxy_busy_buffers_size 64k;
98 proxy_busy_buffers_size 64k;
99 proxy_temp_file_write_size 64k;
99 proxy_temp_file_write_size 64k;
100
100
101 Also when using root path with nginx You might set the static files to false
101 Also when using root path with nginx You might set the static files to false
102 in production.ini file::
102 in production.ini file::
103
103
104 [app:main]
104 [app:main]
105 use = egg:rhodecode
105 use = egg:rhodecode
106 full_stack = true
106 full_stack = true
107 static_files = false
107 static_files = false
108 lang=en
108 lang=en
109 cache_dir = %(here)s/data
109 cache_dir = %(here)s/data
110
110
111 To not have the statics served by the application. And improve speed.
111 To not have the statics served by the application. And improve speed.
112
112
113
113
114 Other configuration files
114 Other configuration files
115 -------------------------
115 -------------------------
116
116
117 Some extra configuration files and examples can be found here:
117 Some extra configuration files and examples can be found here:
118 http://hg.python-works.com/rhodecode/files/tip/init.d
118 http://hg.python-works.com/rhodecode/files/tip/init.d
119
119
120 and also an celeryconfig file can be use from here:
120 and also an celeryconfig file can be use from here:
121 http://hg.python-works.com/rhodecode/files/tip/celeryconfig.py
121 http://hg.python-works.com/rhodecode/files/tip/celeryconfig.py
122
122
123
123
124
124
125 .. _virtualenv: http://pypi.python.org/pypi/virtualenv
125 .. _virtualenv: http://pypi.python.org/pypi/virtualenv
126 .. _python: http://www.python.org/
126 .. _python: http://www.python.org/
127 .. _mercurial: http://mercurial.selenic.com/
127 .. _mercurial: http://mercurial.selenic.com/
128 .. _celery: http://celeryproject.org/
128 .. _celery: http://celeryproject.org/
129 .. _rabbitmq: http://www.rabbitmq.com/ No newline at end of file
129 .. _rabbitmq: http://www.rabbitmq.com/
@@ -1,171 +1,172 b''
1 ################################################################################
1 ################################################################################
2 ################################################################################
2 ################################################################################
3 # rhodecode - Pylons environment configuration #
3 # rhodecode - Pylons environment configuration #
4 # #
4 # #
5 # The %(here)s variable will be replaced with the parent directory of this file#
5 # The %(here)s variable will be replaced with the parent directory of this file#
6 ################################################################################
6 ################################################################################
7
7
8 [DEFAULT]
8 [DEFAULT]
9 debug = true
9 debug = true
10 ################################################################################
10 ################################################################################
11 ## Uncomment and replace with the address which should receive ##
11 ## Uncomment and replace with the address which should receive ##
12 ## any error reports after application crash ##
12 ## any error reports after application crash ##
13 ## Additionally those settings will be used by rhodecode mailing system ##
13 ## Additionally those settings will be used by rhodecode mailing system ##
14 ################################################################################
14 ################################################################################
15 #email_to = admin@localhost
15 #email_to = admin@localhost
16 #error_email_from = paste_error@localhost
16 #error_email_from = paste_error@localhost
17 #app_email_from = rhodecode-noreply@localhost
17 #app_email_from = rhodecode-noreply@localhost
18 #error_message =
18 #error_message =
19
19
20 #smtp_server = mail.server.com
20 #smtp_server = mail.server.com
21 #smtp_username =
21 #smtp_username =
22 #smtp_password =
22 #smtp_password =
23 #smtp_port =
23 #smtp_port =
24 #smtp_use_tls = false
24 #smtp_use_tls = false
25
25
26 [server:main]
26 [server:main]
27 ##nr of threads to spawn
27 ##nr of threads to spawn
28 threadpool_workers = 5
28 threadpool_workers = 5
29
29
30 ##max request before thread respawn
30 ##max request before thread respawn
31 threadpool_max_requests = 2
31 threadpool_max_requests = 2
32
32
33 ##option to use threads of process
33 ##option to use threads of process
34 use_threadpool = true
34 use_threadpool = true
35
35
36 use = egg:Paste#http
36 use = egg:Paste#http
37 host = 127.0.0.1
37 host = 127.0.0.1
38 port = 8001
38 port = 8001
39
39
40 [app:main]
40 [app:main]
41 use = egg:rhodecode
41 use = egg:rhodecode
42 full_stack = true
42 full_stack = true
43 static_files = false
43 static_files = false
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46
46
47 ####################################
47 ####################################
48 ### BEAKER CACHE ####
48 ### BEAKER CACHE ####
49 ####################################
49 ####################################
50 beaker.cache.data_dir=/%(here)s/data/cache/data
50 beaker.cache.data_dir=/%(here)s/data/cache/data
51 beaker.cache.lock_dir=/%(here)s/data/cache/lock
51 beaker.cache.lock_dir=/%(here)s/data/cache/lock
52 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
52 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
53 beaker.cache.long_term.type=memory
54 beaker.cache.long_term.expire=36000
55
53
56 beaker.cache.short_term.type=memory
54 beaker.cache.super_short_term.type=memory
57 beaker.cache.short_term.expire=60
55 beaker.cache.super_short_term.expire=10
56
57 beaker.cache.short_term.type=memory
58 beaker.cache.short_term.expire=60
58
59
59 beaker.cache.super_short_term.type=memory
60 beaker.cache.long_term.type=memory
60 beaker.cache.super_short_term.expire=10
61 beaker.cache.long_term.expire=36000
61
62
62 beaker.cache.sql_cache_short.type=memory
63 beaker.cache.sql_cache_short.type=memory
63 beaker.cache.sql_cache_short.expire=5
64 beaker.cache.sql_cache_short.expire=5
64
65
65 beaker.cache.sql_cache_med.type=memory
66 beaker.cache.sql_cache_med.type=memory
66 beaker.cache.sql_cache_med.expire=360
67 beaker.cache.sql_cache_med.expire=360
67
68
68 beaker.cache.sql_cache_long.type=file
69 beaker.cache.sql_cache_long.type=file
69 beaker.cache.sql_cache_long.expire=3600
70 beaker.cache.sql_cache_long.expire=3600
70
71
71 ####################################
72 ####################################
72 ### BEAKER SESSION ####
73 ### BEAKER SESSION ####
73 ####################################
74 ####################################
74 ## Type of storage used for the session, current types are
75 ## Type of storage used for the session, current types are
75 ## "dbm", "file", "memcached", "database", and "memory".
76 ## "dbm", "file", "memcached", "database", and "memory".
76 ## The storage uses the Container API
77 ## The storage uses the Container API
77 ##that is also used by the cache system.
78 ##that is also used by the cache system.
78 beaker.session.type = file
79 beaker.session.type = file
79
80
80 beaker.session.key = rhodecode
81 beaker.session.key = rhodecode
81 beaker.session.secret = g654dcno0-9873jhgfreyu
82 beaker.session.secret = g654dcno0-9873jhgfreyu
82 beaker.session.timeout = 36000
83 beaker.session.timeout = 36000
83
84
84 ##auto save the session to not to use .save()
85 ##auto save the session to not to use .save()
85 beaker.session.auto = False
86 beaker.session.auto = False
86
87
87 ##true exire at browser close
88 ##true exire at browser close
88 #beaker.session.cookie_expires = 3600
89 #beaker.session.cookie_expires = 3600
89
90
90
91
91 ################################################################################
92 ################################################################################
92 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
93 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
93 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
94 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
94 ## execute malicious code after an exception is raised. ##
95 ## execute malicious code after an exception is raised. ##
95 ################################################################################
96 ################################################################################
96 set debug = false
97 set debug = false
97
98
98 ##################################
99 ##################################
99 ### LOGVIEW CONFIG ###
100 ### LOGVIEW CONFIG ###
100 ##################################
101 ##################################
101 logview.sqlalchemy = #faa
102 logview.sqlalchemy = #faa
102 logview.pylons.templating = #bfb
103 logview.pylons.templating = #bfb
103 logview.pylons.util = #eee
104 logview.pylons.util = #eee
104
105
105 #########################################################
106 #########################################################
106 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
107 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
107 #########################################################
108 #########################################################
108 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
109 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
109 #sqlalchemy.db1.echo = False
110 #sqlalchemy.db1.echo = False
110 #sqlalchemy.db1.pool_recycle = 3600
111 #sqlalchemy.db1.pool_recycle = 3600
111 sqlalchemy.convert_unicode = true
112 sqlalchemy.convert_unicode = true
112
113
113 ################################
114 ################################
114 ### LOGGING CONFIGURATION ####
115 ### LOGGING CONFIGURATION ####
115 ################################
116 ################################
116 [loggers]
117 [loggers]
117 keys = root, routes, rhodecode, sqlalchemy
118 keys = root, routes, rhodecode, sqlalchemy
118
119
119 [handlers]
120 [handlers]
120 keys = console
121 keys = console
121
122
122 [formatters]
123 [formatters]
123 keys = generic,color_formatter
124 keys = generic,color_formatter
124
125
125 #############
126 #############
126 ## LOGGERS ##
127 ## LOGGERS ##
127 #############
128 #############
128 [logger_root]
129 [logger_root]
129 level = INFO
130 level = INFO
130 handlers = console
131 handlers = console
131
132
132 [logger_routes]
133 [logger_routes]
133 level = INFO
134 level = INFO
134 handlers = console
135 handlers = console
135 qualname = routes.middleware
136 qualname = routes.middleware
136 # "level = DEBUG" logs the route matched and routing variables.
137 # "level = DEBUG" logs the route matched and routing variables.
137
138
138 [logger_rhodecode]
139 [logger_rhodecode]
139 level = DEBUG
140 level = DEBUG
140 handlers = console
141 handlers = console
141 qualname = rhodecode
142 qualname = rhodecode
142 propagate = 0
143 propagate = 0
143
144
144 [logger_sqlalchemy]
145 [logger_sqlalchemy]
145 level = ERROR
146 level = ERROR
146 handlers = console
147 handlers = console
147 qualname = sqlalchemy.engine
148 qualname = sqlalchemy.engine
148 propagate = 0
149 propagate = 0
149
150
150 ##############
151 ##############
151 ## HANDLERS ##
152 ## HANDLERS ##
152 ##############
153 ##############
153
154
154 [handler_console]
155 [handler_console]
155 class = StreamHandler
156 class = StreamHandler
156 args = (sys.stderr,)
157 args = (sys.stderr,)
157 level = NOTSET
158 level = NOTSET
158 formatter = color_formatter
159 formatter = color_formatter
159
160
160 ################
161 ################
161 ## FORMATTERS ##
162 ## FORMATTERS ##
162 ################
163 ################
163
164
164 [formatter_generic]
165 [formatter_generic]
165 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
166 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
166 datefmt = %Y-%m-%d %H:%M:%S
167 datefmt = %Y-%m-%d %H:%M:%S
167
168
168 [formatter_color_formatter]
169 [formatter_color_formatter]
169 class=rhodecode.lib.colored_formatter.ColorFormatter
170 class=rhodecode.lib.colored_formatter.ColorFormatter
170 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
171 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
171 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
172 datefmt = %Y-%m-%d %H:%M:%S
@@ -1,172 +1,173 b''
1 ################################################################################
1 ################################################################################
2 ################################################################################
2 ################################################################################
3 # rhodecode - Pylons environment configuration #
3 # rhodecode - Pylons environment configuration #
4 # #
4 # #
5 # The %(here)s variable will be replaced with the parent directory of this file#
5 # The %(here)s variable will be replaced with the parent directory of this file#
6 ################################################################################
6 ################################################################################
7
7
8 [DEFAULT]
8 [DEFAULT]
9 debug = true
9 debug = true
10 ################################################################################
10 ################################################################################
11 ## Uncomment and replace with the address which should receive ##
11 ## Uncomment and replace with the address which should receive ##
12 ## any error reports after application crash ##
12 ## any error reports after application crash ##
13 ## Additionally those settings will be used by rhodecode mailing system ##
13 ## Additionally those settings will be used by rhodecode mailing system ##
14 ################################################################################
14 ################################################################################
15 #email_to = admin@localhost
15 #email_to = admin@localhost
16 #error_email_from = paste_error@localhost
16 #error_email_from = paste_error@localhost
17 #app_email_from = rhodecode-noreply@localhost
17 #app_email_from = rhodecode-noreply@localhost
18 #error_message =
18 #error_message =
19
19
20 #smtp_server = mail.server.com
20 #smtp_server = mail.server.com
21 #smtp_username =
21 #smtp_username =
22 #smtp_password =
22 #smtp_password =
23 #smtp_port =
23 #smtp_port =
24 #smtp_use_tls = false
24 #smtp_use_tls = false
25
25
26 [server:main]
26 [server:main]
27 ##nr of threads to spawn
27 ##nr of threads to spawn
28 threadpool_workers = 5
28 threadpool_workers = 5
29
29
30 ##max request before thread respawn
30 ##max request before thread respawn
31 threadpool_max_requests = 2
31 threadpool_max_requests = 2
32
32
33 ##option to use threads of process
33 ##option to use threads of process
34 use_threadpool = true
34 use_threadpool = true
35
35
36 use = egg:Paste#http
36 use = egg:Paste#http
37 host = 127.0.0.1
37 host = 127.0.0.1
38 port = 5000
38 port = 5000
39
39
40 [app:main]
40 [app:main]
41 use = egg:rhodecode
41 use = egg:rhodecode
42 full_stack = true
42 full_stack = true
43 static_files = true
43 static_files = true
44 lang=en
44 lang=en
45 cache_dir = %(here)s/data
45 cache_dir = %(here)s/data
46 app_instance_uuid = ${app_instance_uuid}
46 app_instance_uuid = ${app_instance_uuid}
47
47
48 ####################################
48 ####################################
49 ### BEAKER CACHE ####
49 ### BEAKER CACHE ####
50 ####################################
50 ####################################
51 beaker.cache.data_dir=/%(here)s/data/cache/data
51 beaker.cache.data_dir=/%(here)s/data/cache/data
52 beaker.cache.lock_dir=/%(here)s/data/cache/lock
52 beaker.cache.lock_dir=/%(here)s/data/cache/lock
53 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
53 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
54 beaker.cache.long_term.type=memory
55 beaker.cache.long_term.expire=36000
56
54
57 beaker.cache.short_term.type=memory
55 beaker.cache.super_short_term.type=memory
58 beaker.cache.short_term.expire=60
56 beaker.cache.super_short_term.expire=10
57
58 beaker.cache.short_term.type=memory
59 beaker.cache.short_term.expire=60
59
60
60 beaker.cache.super_short_term.type=memory
61 beaker.cache.long_term.type=memory
61 beaker.cache.super_short_term.expire=10
62 beaker.cache.long_term.expire=36000
62
63
63 beaker.cache.sql_cache_short.type=memory
64 beaker.cache.sql_cache_short.type=memory
64 beaker.cache.sql_cache_short.expire=5
65 beaker.cache.sql_cache_short.expire=5
65
66
66 beaker.cache.sql_cache_med.type=memory
67 beaker.cache.sql_cache_med.type=memory
67 beaker.cache.sql_cache_med.expire=360
68 beaker.cache.sql_cache_med.expire=360
68
69
69 beaker.cache.sql_cache_long.type=file
70 beaker.cache.sql_cache_long.type=file
70 beaker.cache.sql_cache_long.expire=3600
71 beaker.cache.sql_cache_long.expire=3600
71
72
72 ####################################
73 ####################################
73 ### BEAKER SESSION ####
74 ### BEAKER SESSION ####
74 ####################################
75 ####################################
75 ## Type of storage used for the session, current types are
76 ## Type of storage used for the session, current types are
76 ## "dbm", "file", "memcached", "database", and "memory".
77 ## "dbm", "file", "memcached", "database", and "memory".
77 ## The storage uses the Container API
78 ## The storage uses the Container API
78 ##that is also used by the cache system.
79 ##that is also used by the cache system.
79 beaker.session.type = file
80 beaker.session.type = file
80
81
81 beaker.session.key = rhodecode
82 beaker.session.key = rhodecode
82 beaker.session.secret = ${app_instance_secret}
83 beaker.session.secret = ${app_instance_secret}
83 beaker.session.timeout = 36000
84 beaker.session.timeout = 36000
84
85
85 ##auto save the session to not to use .save()
86 ##auto save the session to not to use .save()
86 beaker.session.auto = False
87 beaker.session.auto = False
87
88
88 ##true exire at browser close
89 ##true exire at browser close
89 #beaker.session.cookie_expires = 3600
90 #beaker.session.cookie_expires = 3600
90
91
91
92
92 ################################################################################
93 ################################################################################
93 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
94 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
94 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
95 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
95 ## execute malicious code after an exception is raised. ##
96 ## execute malicious code after an exception is raised. ##
96 ################################################################################
97 ################################################################################
97 set debug = false
98 set debug = false
98
99
99 ##################################
100 ##################################
100 ### LOGVIEW CONFIG ###
101 ### LOGVIEW CONFIG ###
101 ##################################
102 ##################################
102 logview.sqlalchemy = #faa
103 logview.sqlalchemy = #faa
103 logview.pylons.templating = #bfb
104 logview.pylons.templating = #bfb
104 logview.pylons.util = #eee
105 logview.pylons.util = #eee
105
106
106 #########################################################
107 #########################################################
107 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
108 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
108 #########################################################
109 #########################################################
109 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
110 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
110 #sqlalchemy.db1.echo = False
111 #sqlalchemy.db1.echo = False
111 #sqlalchemy.db1.pool_recycle = 3600
112 #sqlalchemy.db1.pool_recycle = 3600
112 sqlalchemy.convert_unicode = true
113 sqlalchemy.convert_unicode = true
113
114
114 ################################
115 ################################
115 ### LOGGING CONFIGURATION ####
116 ### LOGGING CONFIGURATION ####
116 ################################
117 ################################
117 [loggers]
118 [loggers]
118 keys = root, routes, rhodecode, sqlalchemy
119 keys = root, routes, rhodecode, sqlalchemy
119
120
120 [handlers]
121 [handlers]
121 keys = console
122 keys = console
122
123
123 [formatters]
124 [formatters]
124 keys = generic,color_formatter
125 keys = generic,color_formatter
125
126
126 #############
127 #############
127 ## LOGGERS ##
128 ## LOGGERS ##
128 #############
129 #############
129 [logger_root]
130 [logger_root]
130 level = INFO
131 level = INFO
131 handlers = console
132 handlers = console
132
133
133 [logger_routes]
134 [logger_routes]
134 level = INFO
135 level = INFO
135 handlers = console
136 handlers = console
136 qualname = routes.middleware
137 qualname = routes.middleware
137 # "level = DEBUG" logs the route matched and routing variables.
138 # "level = DEBUG" logs the route matched and routing variables.
138
139
139 [logger_rhodecode]
140 [logger_rhodecode]
140 level = DEBUG
141 level = DEBUG
141 handlers = console
142 handlers = console
142 qualname = rhodecode
143 qualname = rhodecode
143 propagate = 0
144 propagate = 0
144
145
145 [logger_sqlalchemy]
146 [logger_sqlalchemy]
146 level = ERROR
147 level = ERROR
147 handlers = console
148 handlers = console
148 qualname = sqlalchemy.engine
149 qualname = sqlalchemy.engine
149 propagate = 0
150 propagate = 0
150
151
151 ##############
152 ##############
152 ## HANDLERS ##
153 ## HANDLERS ##
153 ##############
154 ##############
154
155
155 [handler_console]
156 [handler_console]
156 class = StreamHandler
157 class = StreamHandler
157 args = (sys.stderr,)
158 args = (sys.stderr,)
158 level = NOTSET
159 level = NOTSET
159 formatter = color_formatter
160 formatter = color_formatter
160
161
161 ################
162 ################
162 ## FORMATTERS ##
163 ## FORMATTERS ##
163 ################
164 ################
164
165
165 [formatter_generic]
166 [formatter_generic]
166 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
167 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
167 datefmt = %Y-%m-%d %H:%M:%S
168 datefmt = %Y-%m-%d %H:%M:%S
168
169
169 [formatter_color_formatter]
170 [formatter_color_formatter]
170 class=rhodecode.lib.colored_formatter.ColorFormatter
171 class=rhodecode.lib.colored_formatter.ColorFormatter
171 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
172 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
172 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
173 datefmt = %Y-%m-%d %H:%M:%S
@@ -1,270 +1,287 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # encoding: utf-8
2 # encoding: utf-8
3 # database management for RhodeCode
3 # database management for RhodeCode
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; version 2
8 # as published by the Free Software Foundation; version 2
9 # of the License or (at your opinion) any later version of the license.
9 # of the License or (at your opinion) any later version of the license.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
19 # MA 02110-1301, USA.
20
20
21 """
21 """
22 Created on April 10, 2010
22 Created on April 10, 2010
23 database management and creation for RhodeCode
23 database management and creation for RhodeCode
24 @author: marcink
24 @author: marcink
25 """
25 """
26
26
27 from os.path import dirname as dn, join as jn
27 from os.path import dirname as dn, join as jn
28 import os
28 import os
29 import sys
29 import sys
30 import uuid
30 import uuid
31
31
32 from rhodecode.lib.auth import get_crypt_password
32 from rhodecode.lib.auth import get_crypt_password
33 from rhodecode.lib.utils import ask_ok
33 from rhodecode.lib.utils import ask_ok
34 from rhodecode.model import init_model
34 from rhodecode.model import init_model
35 from rhodecode.model.db import User, Permission, RhodeCodeUi, RhodeCodeSettings, \
35 from rhodecode.model.db import User, Permission, RhodeCodeUi, RhodeCodeSettings, \
36 UserToPerm
36 UserToPerm
37 from rhodecode.model import meta
37 from rhodecode.model import meta
38 from sqlalchemy.engine import create_engine
38 from sqlalchemy.engine import create_engine
39 import logging
39 import logging
40
40
41 log = logging.getLogger(__name__)
41 log = logging.getLogger(__name__)
42
42
43 class DbManage(object):
43 class DbManage(object):
44 def __init__(self, log_sql, dbname, root, tests=False):
44 def __init__(self, log_sql, dbname, root, tests=False):
45 self.dbname = dbname
45 self.dbname = dbname
46 self.tests = tests
46 self.tests = tests
47 self.root = root
47 self.root = root
48 dburi = 'sqlite:////%s' % jn(self.root, self.dbname)
48 dburi = 'sqlite:////%s' % jn(self.root, self.dbname)
49 engine = create_engine(dburi, echo=log_sql)
49 engine = create_engine(dburi, echo=log_sql)
50 init_model(engine)
50 init_model(engine)
51 self.sa = meta.Session
51 self.sa = meta.Session
52 self.db_exists = False
52 self.db_exists = False
53
53
54 def check_for_db(self, override):
54 def check_for_db(self, override):
55 db_path = jn(self.root, self.dbname)
55 db_path = jn(self.root, self.dbname)
56 log.info('checking for existing db in %s', db_path)
56 log.info('checking for existing db in %s', db_path)
57 if os.path.isfile(db_path):
57 if os.path.isfile(db_path):
58 self.db_exists = True
58 self.db_exists = True
59 log.info('database exist')
60 if not override:
59 if not override:
61 raise Exception('database already exists')
60 raise Exception('database already exists')
62
61
63 def create_tables(self, override=False):
62 def create_tables(self, override=False):
64 """
63 """
65 Create a auth database
64 Create a auth database
66 """
65 """
67 self.check_for_db(override)
66 self.check_for_db(override)
68 if override:
67 if self.db_exists:
69 log.info("database exist and it's going to be destroyed")
68 log.info("database exist and it's going to be destroyed")
70 if self.tests:
69 if self.tests:
71 destroy = True
70 destroy = True
72 else:
71 else:
73 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
72 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
74 if not destroy:
73 if not destroy:
75 sys.exit()
74 sys.exit()
76 if self.db_exists and destroy:
75 if self.db_exists and destroy:
77 os.remove(jn(self.root, self.dbname))
76 os.remove(jn(self.root, self.dbname))
78 checkfirst = not override
77 checkfirst = not override
79 meta.Base.metadata.create_all(checkfirst=checkfirst)
78 meta.Base.metadata.create_all(checkfirst=checkfirst)
80 log.info('Created tables for %s', self.dbname)
79 log.info('Created tables for %s', self.dbname)
81
80
82 def admin_prompt(self):
81 def admin_prompt(self, second=False):
83 if not self.tests:
82 if not self.tests:
84 import getpass
83 import getpass
84
85
86 def get_password():
87 password = getpass.getpass('Specify admin password (min 6 chars):')
88 confirm = getpass.getpass('Confirm password:')
89
90 if password != confirm:
91 log.error('passwords mismatch')
92 return False
93 if len(password) < 6:
94 log.error('password is to short use at least 6 characters')
95 return False
96
97 return password
98
85 username = raw_input('Specify admin username:')
99 username = raw_input('Specify admin username:')
86 password = getpass.getpass('Specify admin password:')
100
87 confirm = getpass.getpass('Confirm password:')
101 password = get_password()
88 if password != confirm:
102 if not password:
89 log.error('passwords mismatch')
103 #second try
90 sys.exit()
104 password = get_password()
105 if not password:
106 sys.exit()
107
91 email = raw_input('Specify admin email:')
108 email = raw_input('Specify admin email:')
92 self.create_user(username, password, email, True)
109 self.create_user(username, password, email, True)
93 else:
110 else:
94 log.info('creating admin and regular test users')
111 log.info('creating admin and regular test users')
95 self.create_user('test_admin', 'test12', 'test_admin@mail.com', True)
112 self.create_user('test_admin', 'test12', 'test_admin@mail.com', True)
96 self.create_user('test_regular', 'test12', 'test_regular@mail.com', False)
113 self.create_user('test_regular', 'test12', 'test_regular@mail.com', False)
97 self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False)
114 self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False)
98
115
99
116
100
117
101 def config_prompt(self, test_repo_path=''):
118 def config_prompt(self, test_repo_path=''):
102 log.info('Setting up repositories config')
119 log.info('Setting up repositories config')
103
120
104 if not self.tests and not test_repo_path:
121 if not self.tests and not test_repo_path:
105 path = raw_input('Specify valid full path to your repositories'
122 path = raw_input('Specify valid full path to your repositories'
106 ' you can change this later in application settings:')
123 ' you can change this later in application settings:')
107 else:
124 else:
108 path = test_repo_path
125 path = test_repo_path
109
126
110 if not os.path.isdir(path):
127 if not os.path.isdir(path):
111 log.error('You entered wrong path: %s', path)
128 log.error('You entered wrong path: %s', path)
112 sys.exit()
129 sys.exit()
113
130
114 hooks1 = RhodeCodeUi()
131 hooks1 = RhodeCodeUi()
115 hooks1.ui_section = 'hooks'
132 hooks1.ui_section = 'hooks'
116 hooks1.ui_key = 'changegroup.update'
133 hooks1.ui_key = 'changegroup.update'
117 hooks1.ui_value = 'hg update >&2'
134 hooks1.ui_value = 'hg update >&2'
118 hooks1.ui_active = False
135 hooks1.ui_active = False
119
136
120 hooks2 = RhodeCodeUi()
137 hooks2 = RhodeCodeUi()
121 hooks2.ui_section = 'hooks'
138 hooks2.ui_section = 'hooks'
122 hooks2.ui_key = 'changegroup.repo_size'
139 hooks2.ui_key = 'changegroup.repo_size'
123 hooks2.ui_value = 'python:rhodecode.lib.hooks.repo_size'
140 hooks2.ui_value = 'python:rhodecode.lib.hooks.repo_size'
124
141
125 web1 = RhodeCodeUi()
142 web1 = RhodeCodeUi()
126 web1.ui_section = 'web'
143 web1.ui_section = 'web'
127 web1.ui_key = 'push_ssl'
144 web1.ui_key = 'push_ssl'
128 web1.ui_value = 'false'
145 web1.ui_value = 'false'
129
146
130 web2 = RhodeCodeUi()
147 web2 = RhodeCodeUi()
131 web2.ui_section = 'web'
148 web2.ui_section = 'web'
132 web2.ui_key = 'allow_archive'
149 web2.ui_key = 'allow_archive'
133 web2.ui_value = 'gz zip bz2'
150 web2.ui_value = 'gz zip bz2'
134
151
135 web3 = RhodeCodeUi()
152 web3 = RhodeCodeUi()
136 web3.ui_section = 'web'
153 web3.ui_section = 'web'
137 web3.ui_key = 'allow_push'
154 web3.ui_key = 'allow_push'
138 web3.ui_value = '*'
155 web3.ui_value = '*'
139
156
140 web4 = RhodeCodeUi()
157 web4 = RhodeCodeUi()
141 web4.ui_section = 'web'
158 web4.ui_section = 'web'
142 web4.ui_key = 'baseurl'
159 web4.ui_key = 'baseurl'
143 web4.ui_value = '/'
160 web4.ui_value = '/'
144
161
145 paths = RhodeCodeUi()
162 paths = RhodeCodeUi()
146 paths.ui_section = 'paths'
163 paths.ui_section = 'paths'
147 paths.ui_key = '/'
164 paths.ui_key = '/'
148 paths.ui_value = os.path.join(path, '*')
165 paths.ui_value = os.path.join(path, '*')
149
166
150
167
151 hgsettings1 = RhodeCodeSettings()
168 hgsettings1 = RhodeCodeSettings()
152
169
153 hgsettings1.app_settings_name = 'realm'
170 hgsettings1.app_settings_name = 'realm'
154 hgsettings1.app_settings_value = 'RhodeCode authentication'
171 hgsettings1.app_settings_value = 'RhodeCode authentication'
155
172
156 hgsettings2 = RhodeCodeSettings()
173 hgsettings2 = RhodeCodeSettings()
157 hgsettings2.app_settings_name = 'title'
174 hgsettings2.app_settings_name = 'title'
158 hgsettings2.app_settings_value = 'RhodeCode'
175 hgsettings2.app_settings_value = 'RhodeCode'
159
176
160 try:
177 try:
161 self.sa.add(hooks1)
178 self.sa.add(hooks1)
162 self.sa.add(hooks2)
179 self.sa.add(hooks2)
163 self.sa.add(web1)
180 self.sa.add(web1)
164 self.sa.add(web2)
181 self.sa.add(web2)
165 self.sa.add(web3)
182 self.sa.add(web3)
166 self.sa.add(web4)
183 self.sa.add(web4)
167 self.sa.add(paths)
184 self.sa.add(paths)
168 self.sa.add(hgsettings1)
185 self.sa.add(hgsettings1)
169 self.sa.add(hgsettings2)
186 self.sa.add(hgsettings2)
170 self.sa.commit()
187 self.sa.commit()
171 except:
188 except:
172 self.sa.rollback()
189 self.sa.rollback()
173 raise
190 raise
174 log.info('created ui config')
191 log.info('created ui config')
175
192
176 def create_user(self, username, password, email='', admin=False):
193 def create_user(self, username, password, email='', admin=False):
177 log.info('creating administrator user %s', username)
194 log.info('creating administrator user %s', username)
178 new_user = User()
195 new_user = User()
179 new_user.username = username
196 new_user.username = username
180 new_user.password = get_crypt_password(password)
197 new_user.password = get_crypt_password(password)
181 new_user.name = 'RhodeCode'
198 new_user.name = 'RhodeCode'
182 new_user.lastname = 'Admin'
199 new_user.lastname = 'Admin'
183 new_user.email = email
200 new_user.email = email
184 new_user.admin = admin
201 new_user.admin = admin
185 new_user.active = True
202 new_user.active = True
186
203
187 try:
204 try:
188 self.sa.add(new_user)
205 self.sa.add(new_user)
189 self.sa.commit()
206 self.sa.commit()
190 except:
207 except:
191 self.sa.rollback()
208 self.sa.rollback()
192 raise
209 raise
193
210
194 def create_default_user(self):
211 def create_default_user(self):
195 log.info('creating default user')
212 log.info('creating default user')
196 #create default user for handling default permissions.
213 #create default user for handling default permissions.
197 def_user = User()
214 def_user = User()
198 def_user.username = 'default'
215 def_user.username = 'default'
199 def_user.password = get_crypt_password(str(uuid.uuid1())[:8])
216 def_user.password = get_crypt_password(str(uuid.uuid1())[:8])
200 def_user.name = 'default'
217 def_user.name = 'default'
201 def_user.lastname = 'default'
218 def_user.lastname = 'default'
202 def_user.email = 'default@default.com'
219 def_user.email = 'default@default.com'
203 def_user.admin = False
220 def_user.admin = False
204 def_user.active = False
221 def_user.active = False
205 try:
222 try:
206 self.sa.add(def_user)
223 self.sa.add(def_user)
207 self.sa.commit()
224 self.sa.commit()
208 except:
225 except:
209 self.sa.rollback()
226 self.sa.rollback()
210 raise
227 raise
211
228
212 def create_permissions(self):
229 def create_permissions(self):
213 #module.(access|create|change|delete)_[name]
230 #module.(access|create|change|delete)_[name]
214 #module.(read|write|owner)
231 #module.(read|write|owner)
215 perms = [('repository.none', 'Repository no access'),
232 perms = [('repository.none', 'Repository no access'),
216 ('repository.read', 'Repository read access'),
233 ('repository.read', 'Repository read access'),
217 ('repository.write', 'Repository write access'),
234 ('repository.write', 'Repository write access'),
218 ('repository.admin', 'Repository admin access'),
235 ('repository.admin', 'Repository admin access'),
219 ('hg.admin', 'Hg Administrator'),
236 ('hg.admin', 'Hg Administrator'),
220 ('hg.create.repository', 'Repository create'),
237 ('hg.create.repository', 'Repository create'),
221 ('hg.create.none', 'Repository creation disabled'),
238 ('hg.create.none', 'Repository creation disabled'),
222 ('hg.register.none', 'Register disabled'),
239 ('hg.register.none', 'Register disabled'),
223 ('hg.register.manual_activate', 'Register new user with rhodecode without manual activation'),
240 ('hg.register.manual_activate', 'Register new user with rhodecode without manual activation'),
224 ('hg.register.auto_activate', 'Register new user with rhodecode without auto activation'),
241 ('hg.register.auto_activate', 'Register new user with rhodecode without auto activation'),
225 ]
242 ]
226
243
227 for p in perms:
244 for p in perms:
228 new_perm = Permission()
245 new_perm = Permission()
229 new_perm.permission_name = p[0]
246 new_perm.permission_name = p[0]
230 new_perm.permission_longname = p[1]
247 new_perm.permission_longname = p[1]
231 try:
248 try:
232 self.sa.add(new_perm)
249 self.sa.add(new_perm)
233 self.sa.commit()
250 self.sa.commit()
234 except:
251 except:
235 self.sa.rollback()
252 self.sa.rollback()
236 raise
253 raise
237
254
238 def populate_default_permissions(self):
255 def populate_default_permissions(self):
239 log.info('creating default user permissions')
256 log.info('creating default user permissions')
240
257
241 default_user = self.sa.query(User)\
258 default_user = self.sa.query(User)\
242 .filter(User.username == 'default').scalar()
259 .filter(User.username == 'default').scalar()
243
260
244 reg_perm = UserToPerm()
261 reg_perm = UserToPerm()
245 reg_perm.user = default_user
262 reg_perm.user = default_user
246 reg_perm.permission = self.sa.query(Permission)\
263 reg_perm.permission = self.sa.query(Permission)\
247 .filter(Permission.permission_name == 'hg.register.manual_activate')\
264 .filter(Permission.permission_name == 'hg.register.manual_activate')\
248 .scalar()
265 .scalar()
249
266
250 create_repo_perm = UserToPerm()
267 create_repo_perm = UserToPerm()
251 create_repo_perm.user = default_user
268 create_repo_perm.user = default_user
252 create_repo_perm.permission = self.sa.query(Permission)\
269 create_repo_perm.permission = self.sa.query(Permission)\
253 .filter(Permission.permission_name == 'hg.create.repository')\
270 .filter(Permission.permission_name == 'hg.create.repository')\
254 .scalar()
271 .scalar()
255
272
256 default_repo_perm = UserToPerm()
273 default_repo_perm = UserToPerm()
257 default_repo_perm.user = default_user
274 default_repo_perm.user = default_user
258 default_repo_perm.permission = self.sa.query(Permission)\
275 default_repo_perm.permission = self.sa.query(Permission)\
259 .filter(Permission.permission_name == 'repository.read')\
276 .filter(Permission.permission_name == 'repository.read')\
260 .scalar()
277 .scalar()
261
278
262 try:
279 try:
263 self.sa.add(reg_perm)
280 self.sa.add(reg_perm)
264 self.sa.add(create_repo_perm)
281 self.sa.add(create_repo_perm)
265 self.sa.add(default_repo_perm)
282 self.sa.add(default_repo_perm)
266 self.sa.commit()
283 self.sa.commit()
267 except:
284 except:
268 self.sa.rollback()
285 self.sa.rollback()
269 raise
286 raise
270
287
General Comments 0
You need to be logged in to leave comments. Login now