Show More
@@ -1,252 +1,258 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 | pdebug = false |
|
10 | pdebug = false | |
11 | ################################################################################ |
|
11 | ################################################################################ | |
12 | ## Uncomment and replace with the address which should receive ## |
|
12 | ## Uncomment and replace with the address which should receive ## | |
13 | ## any error reports after application crash ## |
|
13 | ## any error reports after application crash ## | |
14 | ## Additionally those settings will be used by RhodeCode mailing system ## |
|
14 | ## Additionally those settings will be used by RhodeCode mailing system ## | |
15 | ################################################################################ |
|
15 | ################################################################################ | |
16 | #email_to = admin@localhost |
|
16 | #email_to = admin@localhost | |
17 | #error_email_from = paste_error@localhost |
|
17 | #error_email_from = paste_error@localhost | |
18 | #app_email_from = rhodecode-noreply@localhost |
|
18 | #app_email_from = rhodecode-noreply@localhost | |
19 | #error_message = |
|
19 | #error_message = | |
20 |
|
20 | |||
21 | #smtp_server = mail.server.com |
|
21 | #smtp_server = mail.server.com | |
22 | #smtp_username = |
|
22 | #smtp_username = | |
23 | #smtp_password = |
|
23 | #smtp_password = | |
24 | #smtp_port = |
|
24 | #smtp_port = | |
25 | #smtp_use_tls = false |
|
25 | #smtp_use_tls = false | |
26 | #smtp_use_ssl = true |
|
26 | #smtp_use_ssl = true | |
27 | # Specify available auth parameters here (e.g. LOGIN PLAIN CRAM-MD5, etc.) |
|
27 | # Specify available auth parameters here (e.g. LOGIN PLAIN CRAM-MD5, etc.) | |
28 | #smtp_auth = |
|
28 | #smtp_auth = | |
29 |
|
29 | |||
30 | [server:main] |
|
30 | [server:main] | |
31 | ##nr of threads to spawn |
|
31 | ##nr of threads to spawn | |
32 | threadpool_workers = 5 |
|
32 | threadpool_workers = 5 | |
33 |
|
33 | |||
34 | ##max request before thread respawn |
|
34 | ##max request before thread respawn | |
35 | threadpool_max_requests = 6 |
|
35 | threadpool_max_requests = 6 | |
36 |
|
36 | |||
37 | ##option to use threads of process |
|
37 | ##option to use threads of process | |
38 | use_threadpool = true |
|
38 | use_threadpool = true | |
39 |
|
39 | |||
40 | use = egg:Paste#http |
|
40 | use = egg:Paste#http | |
41 | host = 0.0.0.0 |
|
41 | host = 0.0.0.0 | |
42 | port = 5000 |
|
42 | port = 5000 | |
43 |
|
43 | |||
44 | [app:main] |
|
44 | [app:main] | |
45 | use = egg:rhodecode |
|
45 | use = egg:rhodecode | |
46 | full_stack = true |
|
46 | full_stack = true | |
47 | static_files = true |
|
47 | static_files = true | |
48 | lang=en |
|
48 | lang=en | |
49 | cache_dir = %(here)s/data |
|
49 | cache_dir = %(here)s/data | |
50 | index_dir = %(here)s/data/index |
|
50 | index_dir = %(here)s/data/index | |
51 | app_instance_uuid = develop |
|
51 | app_instance_uuid = develop | |
52 | cut_off_limit = 256000 |
|
52 | cut_off_limit = 256000 | |
53 | force_https = false |
|
53 | force_https = false | |
54 | commit_parse_limit = 25 |
|
54 | commit_parse_limit = 25 | |
55 | use_gravatar = true |
|
55 | use_gravatar = true | |
56 | container_auth_enabled = false |
|
56 | container_auth_enabled = false | |
57 | proxypass_auth_enabled = false |
|
57 | proxypass_auth_enabled = false | |
58 |
|
58 | |||
59 | ## overwrite schema of clone url |
|
59 | ## overwrite schema of clone url | |
60 | # available vars: |
|
60 | # available vars: | |
61 | # scheme - http/https |
|
61 | # scheme - http/https | |
62 | # user - current user |
|
62 | # user - current user | |
63 | # pass - password |
|
63 | # pass - password | |
64 | # netloc - network location |
|
64 | # netloc - network location | |
65 | # path - usually repo_name |
|
65 | # path - usually repo_name | |
66 | # clone_uri = {scheme}://{user}{pass}{netloc}{path} |
|
66 | # clone_uri = {scheme}://{user}{pass}{netloc}{path} | |
67 |
|
67 | |||
68 | #################################### |
|
68 | #################################### | |
69 | ### CELERY CONFIG #### |
|
69 | ### CELERY CONFIG #### | |
70 | #################################### |
|
70 | #################################### | |
71 | use_celery = false |
|
71 | use_celery = false | |
72 | broker.host = localhost |
|
72 | broker.host = localhost | |
73 | broker.vhost = rabbitmqhost |
|
73 | broker.vhost = rabbitmqhost | |
74 | broker.port = 5672 |
|
74 | broker.port = 5672 | |
75 | broker.user = rabbitmq |
|
75 | broker.user = rabbitmq | |
76 | broker.password = qweqwe |
|
76 | broker.password = qweqwe | |
77 |
|
77 | |||
78 | celery.imports = rhodecode.lib.celerylib.tasks |
|
78 | celery.imports = rhodecode.lib.celerylib.tasks | |
79 |
|
79 | |||
80 | celery.result.backend = amqp |
|
80 | celery.result.backend = amqp | |
81 | celery.result.dburi = amqp:// |
|
81 | celery.result.dburi = amqp:// | |
82 | celery.result.serialier = json |
|
82 | celery.result.serialier = json | |
83 |
|
83 | |||
84 | #celery.send.task.error.emails = true |
|
84 | #celery.send.task.error.emails = true | |
85 | #celery.amqp.task.result.expires = 18000 |
|
85 | #celery.amqp.task.result.expires = 18000 | |
86 |
|
86 | |||
87 | celeryd.concurrency = 2 |
|
87 | celeryd.concurrency = 2 | |
88 | #celeryd.log.file = celeryd.log |
|
88 | #celeryd.log.file = celeryd.log | |
89 | celeryd.log.level = debug |
|
89 | celeryd.log.level = debug | |
90 | celeryd.max.tasks.per.child = 1 |
|
90 | celeryd.max.tasks.per.child = 1 | |
91 |
|
91 | |||
92 | #tasks will never be sent to the queue, but executed locally instead. |
|
92 | #tasks will never be sent to the queue, but executed locally instead. | |
93 | celery.always.eager = false |
|
93 | celery.always.eager = false | |
94 |
|
94 | |||
95 | #################################### |
|
95 | #################################### | |
96 | ### BEAKER CACHE #### |
|
96 | ### BEAKER CACHE #### | |
97 | #################################### |
|
97 | #################################### | |
98 | beaker.cache.data_dir=%(here)s/data/cache/data |
|
98 | beaker.cache.data_dir=%(here)s/data/cache/data | |
99 | beaker.cache.lock_dir=%(here)s/data/cache/lock |
|
99 | beaker.cache.lock_dir=%(here)s/data/cache/lock | |
100 |
|
100 | |||
101 | beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long |
|
101 | beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long | |
102 |
|
102 | |||
103 | beaker.cache.super_short_term.type=memory |
|
103 | beaker.cache.super_short_term.type=memory | |
104 | beaker.cache.super_short_term.expire=10 |
|
104 | beaker.cache.super_short_term.expire=10 | |
105 | beaker.cache.super_short_term.key_length = 256 |
|
105 | beaker.cache.super_short_term.key_length = 256 | |
106 |
|
106 | |||
107 | beaker.cache.short_term.type=memory |
|
107 | beaker.cache.short_term.type=memory | |
108 | beaker.cache.short_term.expire=60 |
|
108 | beaker.cache.short_term.expire=60 | |
109 | beaker.cache.short_term.key_length = 256 |
|
109 | beaker.cache.short_term.key_length = 256 | |
110 |
|
110 | |||
111 | beaker.cache.long_term.type=memory |
|
111 | beaker.cache.long_term.type=memory | |
112 | beaker.cache.long_term.expire=36000 |
|
112 | beaker.cache.long_term.expire=36000 | |
113 | beaker.cache.long_term.key_length = 256 |
|
113 | beaker.cache.long_term.key_length = 256 | |
114 |
|
114 | |||
115 | beaker.cache.sql_cache_short.type=memory |
|
115 | beaker.cache.sql_cache_short.type=memory | |
116 | beaker.cache.sql_cache_short.expire=10 |
|
116 | beaker.cache.sql_cache_short.expire=10 | |
117 | beaker.cache.sql_cache_short.key_length = 256 |
|
117 | beaker.cache.sql_cache_short.key_length = 256 | |
118 |
|
118 | |||
119 | beaker.cache.sql_cache_med.type=memory |
|
119 | beaker.cache.sql_cache_med.type=memory | |
120 | beaker.cache.sql_cache_med.expire=360 |
|
120 | beaker.cache.sql_cache_med.expire=360 | |
121 | beaker.cache.sql_cache_med.key_length = 256 |
|
121 | beaker.cache.sql_cache_med.key_length = 256 | |
122 |
|
122 | |||
123 | beaker.cache.sql_cache_long.type=file |
|
123 | beaker.cache.sql_cache_long.type=file | |
124 | beaker.cache.sql_cache_long.expire=3600 |
|
124 | beaker.cache.sql_cache_long.expire=3600 | |
125 | beaker.cache.sql_cache_long.key_length = 256 |
|
125 | beaker.cache.sql_cache_long.key_length = 256 | |
126 |
|
126 | |||
127 | #################################### |
|
127 | #################################### | |
128 | ### BEAKER SESSION #### |
|
128 | ### BEAKER SESSION #### | |
129 | #################################### |
|
129 | #################################### | |
130 | ## Type of storage used for the session, current types are |
|
130 | ## Type of storage used for the session, current types are | |
131 | ## dbm, file, memcached, database, and memory. |
|
131 | ## dbm, file, memcached, database, and memory. | |
132 | ## The storage uses the Container API |
|
132 | ## The storage uses the Container API | |
133 | ##that is also used by the cache system. |
|
133 | ##that is also used by the cache system. | |
|
134 | ||||
|
135 | #db session example | |||
|
136 | #beaker.session.type = ext:database | |||
|
137 | #beaker.session.sa.url = postgresql://postgres:qwe@localhost/rhodecode | |||
|
138 | #beaker.session.table_name = db_session | |||
|
139 | ||||
134 | beaker.session.type = file |
|
140 | beaker.session.type = file | |
135 |
|
141 | |||
136 | beaker.session.key = rhodecode |
|
142 | beaker.session.key = rhodecode | |
137 | beaker.session.secret = g654dcno0-9873jhgfreyu |
|
143 | beaker.session.secret = g654dcno0-9873jhgfreyu | |
138 | beaker.session.timeout = 36000 |
|
144 | beaker.session.timeout = 36000 | |
139 |
|
145 | |||
140 | ##auto save the session to not to use .save() |
|
146 | ##auto save the session to not to use .save() | |
141 | beaker.session.auto = False |
|
147 | beaker.session.auto = False | |
142 |
|
148 | |||
143 | ##true exire at browser close |
|
149 | ##true exire at browser close | |
144 | #beaker.session.cookie_expires = 3600 |
|
150 | #beaker.session.cookie_expires = 3600 | |
145 |
|
151 | |||
146 |
|
152 | |||
147 | ################################################################################ |
|
153 | ################################################################################ | |
148 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## |
|
154 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## | |
149 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## |
|
155 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## | |
150 | ## execute malicious code after an exception is raised. ## |
|
156 | ## execute malicious code after an exception is raised. ## | |
151 | ################################################################################ |
|
157 | ################################################################################ | |
152 | #set debug = false |
|
158 | #set debug = false | |
153 |
|
159 | |||
154 | ################################## |
|
160 | ################################## | |
155 | ### LOGVIEW CONFIG ### |
|
161 | ### LOGVIEW CONFIG ### | |
156 | ################################## |
|
162 | ################################## | |
157 | logview.sqlalchemy = #faa |
|
163 | logview.sqlalchemy = #faa | |
158 | logview.pylons.templating = #bfb |
|
164 | logview.pylons.templating = #bfb | |
159 | logview.pylons.util = #eee |
|
165 | logview.pylons.util = #eee | |
160 |
|
166 | |||
161 | ######################################################### |
|
167 | ######################################################### | |
162 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### |
|
168 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### | |
163 | ######################################################### |
|
169 | ######################################################### | |
164 | #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db |
|
170 | #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db | |
165 | sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode |
|
171 | sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode | |
166 | sqlalchemy.db1.echo = false |
|
172 | sqlalchemy.db1.echo = false | |
167 | sqlalchemy.db1.pool_recycle = 3600 |
|
173 | sqlalchemy.db1.pool_recycle = 3600 | |
168 | sqlalchemy.convert_unicode = true |
|
174 | sqlalchemy.convert_unicode = true | |
169 |
|
175 | |||
170 | ################################ |
|
176 | ################################ | |
171 | ### LOGGING CONFIGURATION #### |
|
177 | ### LOGGING CONFIGURATION #### | |
172 | ################################ |
|
178 | ################################ | |
173 | [loggers] |
|
179 | [loggers] | |
174 | keys = root, routes, rhodecode, sqlalchemy, beaker, templates |
|
180 | keys = root, routes, rhodecode, sqlalchemy, beaker, templates | |
175 |
|
181 | |||
176 | [handlers] |
|
182 | [handlers] | |
177 | keys = console, console_sql |
|
183 | keys = console, console_sql | |
178 |
|
184 | |||
179 | [formatters] |
|
185 | [formatters] | |
180 | keys = generic, color_formatter, color_formatter_sql |
|
186 | keys = generic, color_formatter, color_formatter_sql | |
181 |
|
187 | |||
182 | ############# |
|
188 | ############# | |
183 | ## LOGGERS ## |
|
189 | ## LOGGERS ## | |
184 | ############# |
|
190 | ############# | |
185 | [logger_root] |
|
191 | [logger_root] | |
186 | level = NOTSET |
|
192 | level = NOTSET | |
187 | handlers = console |
|
193 | handlers = console | |
188 |
|
194 | |||
189 | [logger_routes] |
|
195 | [logger_routes] | |
190 | level = DEBUG |
|
196 | level = DEBUG | |
191 | handlers = |
|
197 | handlers = | |
192 | qualname = routes.middleware |
|
198 | qualname = routes.middleware | |
193 | # "level = DEBUG" logs the route matched and routing variables. |
|
199 | # "level = DEBUG" logs the route matched and routing variables. | |
194 | propagate = 1 |
|
200 | propagate = 1 | |
195 |
|
201 | |||
196 | [logger_beaker] |
|
202 | [logger_beaker] | |
197 | level = DEBUG |
|
203 | level = DEBUG | |
198 | handlers = |
|
204 | handlers = | |
199 | qualname = beaker.container |
|
205 | qualname = beaker.container | |
200 | propagate = 1 |
|
206 | propagate = 1 | |
201 |
|
207 | |||
202 | [logger_templates] |
|
208 | [logger_templates] | |
203 | level = INFO |
|
209 | level = INFO | |
204 | handlers = |
|
210 | handlers = | |
205 | qualname = pylons.templating |
|
211 | qualname = pylons.templating | |
206 | propagate = 1 |
|
212 | propagate = 1 | |
207 |
|
213 | |||
208 | [logger_rhodecode] |
|
214 | [logger_rhodecode] | |
209 | level = DEBUG |
|
215 | level = DEBUG | |
210 | handlers = |
|
216 | handlers = | |
211 | qualname = rhodecode |
|
217 | qualname = rhodecode | |
212 | propagate = 1 |
|
218 | propagate = 1 | |
213 |
|
219 | |||
214 | [logger_sqlalchemy] |
|
220 | [logger_sqlalchemy] | |
215 | level = INFO |
|
221 | level = INFO | |
216 | handlers = console_sql |
|
222 | handlers = console_sql | |
217 | qualname = sqlalchemy.engine |
|
223 | qualname = sqlalchemy.engine | |
218 | propagate = 0 |
|
224 | propagate = 0 | |
219 |
|
225 | |||
220 | ############## |
|
226 | ############## | |
221 | ## HANDLERS ## |
|
227 | ## HANDLERS ## | |
222 | ############## |
|
228 | ############## | |
223 |
|
229 | |||
224 | [handler_console] |
|
230 | [handler_console] | |
225 | class = StreamHandler |
|
231 | class = StreamHandler | |
226 | args = (sys.stderr,) |
|
232 | args = (sys.stderr,) | |
227 | level = DEBUG |
|
233 | level = DEBUG | |
228 | formatter = color_formatter |
|
234 | formatter = color_formatter | |
229 |
|
235 | |||
230 | [handler_console_sql] |
|
236 | [handler_console_sql] | |
231 | class = StreamHandler |
|
237 | class = StreamHandler | |
232 | args = (sys.stderr,) |
|
238 | args = (sys.stderr,) | |
233 | level = DEBUG |
|
239 | level = DEBUG | |
234 | formatter = color_formatter_sql |
|
240 | formatter = color_formatter_sql | |
235 |
|
241 | |||
236 | ################ |
|
242 | ################ | |
237 | ## FORMATTERS ## |
|
243 | ## FORMATTERS ## | |
238 | ################ |
|
244 | ################ | |
239 |
|
245 | |||
240 | [formatter_generic] |
|
246 | [formatter_generic] | |
241 | format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
247 | format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
242 | datefmt = %Y-%m-%d %H:%M:%S |
|
248 | datefmt = %Y-%m-%d %H:%M:%S | |
243 |
|
249 | |||
244 | [formatter_color_formatter] |
|
250 | [formatter_color_formatter] | |
245 | class=rhodecode.lib.colored_formatter.ColorFormatter |
|
251 | class=rhodecode.lib.colored_formatter.ColorFormatter | |
246 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
252 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
247 | datefmt = %Y-%m-%d %H:%M:%S |
|
253 | datefmt = %Y-%m-%d %H:%M:%S | |
248 |
|
254 | |||
249 | [formatter_color_formatter_sql] |
|
255 | [formatter_color_formatter_sql] | |
250 | class=rhodecode.lib.colored_formatter.ColorFormatterSql |
|
256 | class=rhodecode.lib.colored_formatter.ColorFormatterSql | |
251 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
257 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
252 | datefmt = %Y-%m-%d %H:%M:%S |
|
258 | datefmt = %Y-%m-%d %H:%M:%S |
@@ -1,251 +1,257 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 | pdebug = false |
|
10 | pdebug = false | |
11 | ################################################################################ |
|
11 | ################################################################################ | |
12 | ## Uncomment and replace with the address which should receive ## |
|
12 | ## Uncomment and replace with the address which should receive ## | |
13 | ## any error reports after application crash ## |
|
13 | ## any error reports after application crash ## | |
14 | ## Additionally those settings will be used by RhodeCode mailing system ## |
|
14 | ## Additionally those settings will be used by RhodeCode mailing system ## | |
15 | ################################################################################ |
|
15 | ################################################################################ | |
16 | #email_to = admin@localhost |
|
16 | #email_to = admin@localhost | |
17 | #error_email_from = paste_error@localhost |
|
17 | #error_email_from = paste_error@localhost | |
18 | #app_email_from = rhodecode-noreply@localhost |
|
18 | #app_email_from = rhodecode-noreply@localhost | |
19 | #error_message = |
|
19 | #error_message = | |
20 |
|
20 | |||
21 | #smtp_server = mail.server.com |
|
21 | #smtp_server = mail.server.com | |
22 | #smtp_username = |
|
22 | #smtp_username = | |
23 | #smtp_password = |
|
23 | #smtp_password = | |
24 | #smtp_port = |
|
24 | #smtp_port = | |
25 | #smtp_use_tls = false |
|
25 | #smtp_use_tls = false | |
26 | #smtp_use_ssl = true |
|
26 | #smtp_use_ssl = true | |
27 | # Specify available auth parameters here (e.g. LOGIN PLAIN CRAM-MD5, etc.) |
|
27 | # Specify available auth parameters here (e.g. LOGIN PLAIN CRAM-MD5, etc.) | |
28 | #smtp_auth = |
|
28 | #smtp_auth = | |
29 |
|
29 | |||
30 | [server:main] |
|
30 | [server:main] | |
31 | ##nr of threads to spawn |
|
31 | ##nr of threads to spawn | |
32 | threadpool_workers = 5 |
|
32 | threadpool_workers = 5 | |
33 |
|
33 | |||
34 | ##max request before thread respawn |
|
34 | ##max request before thread respawn | |
35 | threadpool_max_requests = 10 |
|
35 | threadpool_max_requests = 10 | |
36 |
|
36 | |||
37 | ##option to use threads of process |
|
37 | ##option to use threads of process | |
38 | use_threadpool = true |
|
38 | use_threadpool = true | |
39 |
|
39 | |||
40 | use = egg:Paste#http |
|
40 | use = egg:Paste#http | |
41 | host = 127.0.0.1 |
|
41 | host = 127.0.0.1 | |
42 | port = 8001 |
|
42 | port = 8001 | |
43 |
|
43 | |||
44 | [app:main] |
|
44 | [app:main] | |
45 | use = egg:rhodecode |
|
45 | use = egg:rhodecode | |
46 | full_stack = true |
|
46 | full_stack = true | |
47 | static_files = true |
|
47 | static_files = true | |
48 | lang=en |
|
48 | lang=en | |
49 | cache_dir = %(here)s/data |
|
49 | cache_dir = %(here)s/data | |
50 | index_dir = %(here)s/data/index |
|
50 | index_dir = %(here)s/data/index | |
51 | app_instance_uuid = prod1234 |
|
51 | app_instance_uuid = prod1234 | |
52 | cut_off_limit = 256000 |
|
52 | cut_off_limit = 256000 | |
53 | force_https = false |
|
53 | force_https = false | |
54 | commit_parse_limit = 50 |
|
54 | commit_parse_limit = 50 | |
55 | use_gravatar = true |
|
55 | use_gravatar = true | |
56 | container_auth_enabled = false |
|
56 | container_auth_enabled = false | |
57 | proxypass_auth_enabled = false |
|
57 | proxypass_auth_enabled = false | |
58 |
|
58 | |||
59 | ## available vars |
|
59 | ## available vars | |
60 | ## scheme - http/https |
|
60 | ## scheme - http/https | |
61 | ## user - current user |
|
61 | ## user - current user | |
62 | ## pass - password |
|
62 | ## pass - password | |
63 | ## netloc - network location |
|
63 | ## netloc - network location | |
64 | ## path - usually repo_name |
|
64 | ## path - usually repo_name | |
65 | clone_uri = {scheme}://{user}{pass}{netloc}{path} |
|
65 | clone_uri = {scheme}://{user}{pass}{netloc}{path} | |
66 |
|
66 | |||
67 | #################################### |
|
67 | #################################### | |
68 | ### CELERY CONFIG #### |
|
68 | ### CELERY CONFIG #### | |
69 | #################################### |
|
69 | #################################### | |
70 | use_celery = false |
|
70 | use_celery = false | |
71 | broker.host = localhost |
|
71 | broker.host = localhost | |
72 | broker.vhost = rabbitmqhost |
|
72 | broker.vhost = rabbitmqhost | |
73 | broker.port = 5672 |
|
73 | broker.port = 5672 | |
74 | broker.user = rabbitmq |
|
74 | broker.user = rabbitmq | |
75 | broker.password = qweqwe |
|
75 | broker.password = qweqwe | |
76 |
|
76 | |||
77 | celery.imports = rhodecode.lib.celerylib.tasks |
|
77 | celery.imports = rhodecode.lib.celerylib.tasks | |
78 |
|
78 | |||
79 | celery.result.backend = amqp |
|
79 | celery.result.backend = amqp | |
80 | celery.result.dburi = amqp:// |
|
80 | celery.result.dburi = amqp:// | |
81 | celery.result.serialier = json |
|
81 | celery.result.serialier = json | |
82 |
|
82 | |||
83 | #celery.send.task.error.emails = true |
|
83 | #celery.send.task.error.emails = true | |
84 | #celery.amqp.task.result.expires = 18000 |
|
84 | #celery.amqp.task.result.expires = 18000 | |
85 |
|
85 | |||
86 | celeryd.concurrency = 2 |
|
86 | celeryd.concurrency = 2 | |
87 | #celeryd.log.file = celeryd.log |
|
87 | #celeryd.log.file = celeryd.log | |
88 | celeryd.log.level = debug |
|
88 | celeryd.log.level = debug | |
89 | celeryd.max.tasks.per.child = 1 |
|
89 | celeryd.max.tasks.per.child = 1 | |
90 |
|
90 | |||
91 | #tasks will never be sent to the queue, but executed locally instead. |
|
91 | #tasks will never be sent to the queue, but executed locally instead. | |
92 | celery.always.eager = false |
|
92 | celery.always.eager = false | |
93 |
|
93 | |||
94 | #################################### |
|
94 | #################################### | |
95 | ### BEAKER CACHE #### |
|
95 | ### BEAKER CACHE #### | |
96 | #################################### |
|
96 | #################################### | |
97 | beaker.cache.data_dir=%(here)s/data/cache/data |
|
97 | beaker.cache.data_dir=%(here)s/data/cache/data | |
98 | beaker.cache.lock_dir=%(here)s/data/cache/lock |
|
98 | beaker.cache.lock_dir=%(here)s/data/cache/lock | |
99 |
|
99 | |||
100 | beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long |
|
100 | beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long | |
101 |
|
101 | |||
102 | beaker.cache.super_short_term.type=memory |
|
102 | beaker.cache.super_short_term.type=memory | |
103 | beaker.cache.super_short_term.expire=10 |
|
103 | beaker.cache.super_short_term.expire=10 | |
104 | beaker.cache.super_short_term.key_length = 256 |
|
104 | beaker.cache.super_short_term.key_length = 256 | |
105 |
|
105 | |||
106 | beaker.cache.short_term.type=memory |
|
106 | beaker.cache.short_term.type=memory | |
107 | beaker.cache.short_term.expire=60 |
|
107 | beaker.cache.short_term.expire=60 | |
108 | beaker.cache.short_term.key_length = 256 |
|
108 | beaker.cache.short_term.key_length = 256 | |
109 |
|
109 | |||
110 | beaker.cache.long_term.type=memory |
|
110 | beaker.cache.long_term.type=memory | |
111 | beaker.cache.long_term.expire=36000 |
|
111 | beaker.cache.long_term.expire=36000 | |
112 | beaker.cache.long_term.key_length = 256 |
|
112 | beaker.cache.long_term.key_length = 256 | |
113 |
|
113 | |||
114 | beaker.cache.sql_cache_short.type=memory |
|
114 | beaker.cache.sql_cache_short.type=memory | |
115 | beaker.cache.sql_cache_short.expire=10 |
|
115 | beaker.cache.sql_cache_short.expire=10 | |
116 | beaker.cache.sql_cache_short.key_length = 256 |
|
116 | beaker.cache.sql_cache_short.key_length = 256 | |
117 |
|
117 | |||
118 | beaker.cache.sql_cache_med.type=memory |
|
118 | beaker.cache.sql_cache_med.type=memory | |
119 | beaker.cache.sql_cache_med.expire=360 |
|
119 | beaker.cache.sql_cache_med.expire=360 | |
120 | beaker.cache.sql_cache_med.key_length = 256 |
|
120 | beaker.cache.sql_cache_med.key_length = 256 | |
121 |
|
121 | |||
122 | beaker.cache.sql_cache_long.type=file |
|
122 | beaker.cache.sql_cache_long.type=file | |
123 | beaker.cache.sql_cache_long.expire=3600 |
|
123 | beaker.cache.sql_cache_long.expire=3600 | |
124 | beaker.cache.sql_cache_long.key_length = 256 |
|
124 | beaker.cache.sql_cache_long.key_length = 256 | |
125 |
|
125 | |||
126 | #################################### |
|
126 | #################################### | |
127 | ### BEAKER SESSION #### |
|
127 | ### BEAKER SESSION #### | |
128 | #################################### |
|
128 | #################################### | |
129 | ## Type of storage used for the session, current types are |
|
129 | ## Type of storage used for the session, current types are | |
130 | ## dbm, file, memcached, database, and memory. |
|
130 | ## dbm, file, memcached, database, and memory. | |
131 | ## The storage uses the Container API |
|
131 | ## The storage uses the Container API | |
132 | ##that is also used by the cache system. |
|
132 | ##that is also used by the cache system. | |
|
133 | ||||
|
134 | #db session example | |||
|
135 | #beaker.session.type = ext:database | |||
|
136 | #beaker.session.sa.url = postgresql://postgres:qwe@localhost/rhodecode | |||
|
137 | #beaker.session.table_name = db_session | |||
|
138 | ||||
133 | beaker.session.type = file |
|
139 | beaker.session.type = file | |
134 |
|
140 | |||
135 | beaker.session.key = rhodecode |
|
141 | beaker.session.key = rhodecode | |
136 | beaker.session.secret = g654dcno0-9873jhgfreyu |
|
142 | beaker.session.secret = g654dcno0-9873jhgfreyu | |
137 | beaker.session.timeout = 36000 |
|
143 | beaker.session.timeout = 36000 | |
138 |
|
144 | |||
139 | ##auto save the session to not to use .save() |
|
145 | ##auto save the session to not to use .save() | |
140 | beaker.session.auto = False |
|
146 | beaker.session.auto = False | |
141 |
|
147 | |||
142 | ##true exire at browser close |
|
148 | ##true exire at browser close | |
143 | #beaker.session.cookie_expires = 3600 |
|
149 | #beaker.session.cookie_expires = 3600 | |
144 |
|
150 | |||
145 |
|
151 | |||
146 | ################################################################################ |
|
152 | ################################################################################ | |
147 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## |
|
153 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## | |
148 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## |
|
154 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## | |
149 | ## execute malicious code after an exception is raised. ## |
|
155 | ## execute malicious code after an exception is raised. ## | |
150 | ################################################################################ |
|
156 | ################################################################################ | |
151 | set debug = false |
|
157 | set debug = false | |
152 |
|
158 | |||
153 | ################################## |
|
159 | ################################## | |
154 | ### LOGVIEW CONFIG ### |
|
160 | ### LOGVIEW CONFIG ### | |
155 | ################################## |
|
161 | ################################## | |
156 | logview.sqlalchemy = #faa |
|
162 | logview.sqlalchemy = #faa | |
157 | logview.pylons.templating = #bfb |
|
163 | logview.pylons.templating = #bfb | |
158 | logview.pylons.util = #eee |
|
164 | logview.pylons.util = #eee | |
159 |
|
165 | |||
160 | ######################################################### |
|
166 | ######################################################### | |
161 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### |
|
167 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### | |
162 | ######################################################### |
|
168 | ######################################################### | |
163 | #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db |
|
169 | #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db | |
164 | sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode |
|
170 | sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode | |
165 | sqlalchemy.db1.echo = false |
|
171 | sqlalchemy.db1.echo = false | |
166 | sqlalchemy.db1.pool_recycle = 3600 |
|
172 | sqlalchemy.db1.pool_recycle = 3600 | |
167 | sqlalchemy.convert_unicode = true |
|
173 | sqlalchemy.convert_unicode = true | |
168 |
|
174 | |||
169 | ################################ |
|
175 | ################################ | |
170 | ### LOGGING CONFIGURATION #### |
|
176 | ### LOGGING CONFIGURATION #### | |
171 | ################################ |
|
177 | ################################ | |
172 | [loggers] |
|
178 | [loggers] | |
173 | keys = root, routes, rhodecode, sqlalchemy, beaker, templates |
|
179 | keys = root, routes, rhodecode, sqlalchemy, beaker, templates | |
174 |
|
180 | |||
175 | [handlers] |
|
181 | [handlers] | |
176 | keys = console, console_sql |
|
182 | keys = console, console_sql | |
177 |
|
183 | |||
178 | [formatters] |
|
184 | [formatters] | |
179 | keys = generic, color_formatter, color_formatter_sql |
|
185 | keys = generic, color_formatter, color_formatter_sql | |
180 |
|
186 | |||
181 | ############# |
|
187 | ############# | |
182 | ## LOGGERS ## |
|
188 | ## LOGGERS ## | |
183 | ############# |
|
189 | ############# | |
184 | [logger_root] |
|
190 | [logger_root] | |
185 | level = NOTSET |
|
191 | level = NOTSET | |
186 | handlers = console |
|
192 | handlers = console | |
187 |
|
193 | |||
188 | [logger_routes] |
|
194 | [logger_routes] | |
189 | level = DEBUG |
|
195 | level = DEBUG | |
190 | handlers = |
|
196 | handlers = | |
191 | qualname = routes.middleware |
|
197 | qualname = routes.middleware | |
192 | # "level = DEBUG" logs the route matched and routing variables. |
|
198 | # "level = DEBUG" logs the route matched and routing variables. | |
193 | propagate = 1 |
|
199 | propagate = 1 | |
194 |
|
200 | |||
195 | [logger_beaker] |
|
201 | [logger_beaker] | |
196 | level = DEBUG |
|
202 | level = DEBUG | |
197 | handlers = |
|
203 | handlers = | |
198 | qualname = beaker.container |
|
204 | qualname = beaker.container | |
199 | propagate = 1 |
|
205 | propagate = 1 | |
200 |
|
206 | |||
201 | [logger_templates] |
|
207 | [logger_templates] | |
202 | level = INFO |
|
208 | level = INFO | |
203 | handlers = |
|
209 | handlers = | |
204 | qualname = pylons.templating |
|
210 | qualname = pylons.templating | |
205 | propagate = 1 |
|
211 | propagate = 1 | |
206 |
|
212 | |||
207 | [logger_rhodecode] |
|
213 | [logger_rhodecode] | |
208 | level = DEBUG |
|
214 | level = DEBUG | |
209 | handlers = |
|
215 | handlers = | |
210 | qualname = rhodecode |
|
216 | qualname = rhodecode | |
211 | propagate = 1 |
|
217 | propagate = 1 | |
212 |
|
218 | |||
213 | [logger_sqlalchemy] |
|
219 | [logger_sqlalchemy] | |
214 | level = INFO |
|
220 | level = INFO | |
215 | handlers = console_sql |
|
221 | handlers = console_sql | |
216 | qualname = sqlalchemy.engine |
|
222 | qualname = sqlalchemy.engine | |
217 | propagate = 0 |
|
223 | propagate = 0 | |
218 |
|
224 | |||
219 | ############## |
|
225 | ############## | |
220 | ## HANDLERS ## |
|
226 | ## HANDLERS ## | |
221 | ############## |
|
227 | ############## | |
222 |
|
228 | |||
223 | [handler_console] |
|
229 | [handler_console] | |
224 | class = StreamHandler |
|
230 | class = StreamHandler | |
225 | args = (sys.stderr,) |
|
231 | args = (sys.stderr,) | |
226 | level = INFO |
|
232 | level = INFO | |
227 | formatter = generic |
|
233 | formatter = generic | |
228 |
|
234 | |||
229 | [handler_console_sql] |
|
235 | [handler_console_sql] | |
230 | class = StreamHandler |
|
236 | class = StreamHandler | |
231 | args = (sys.stderr,) |
|
237 | args = (sys.stderr,) | |
232 | level = WARN |
|
238 | level = WARN | |
233 | formatter = generic |
|
239 | formatter = generic | |
234 |
|
240 | |||
235 | ################ |
|
241 | ################ | |
236 | ## FORMATTERS ## |
|
242 | ## FORMATTERS ## | |
237 | ################ |
|
243 | ################ | |
238 |
|
244 | |||
239 | [formatter_generic] |
|
245 | [formatter_generic] | |
240 | format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
246 | format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
241 | datefmt = %Y-%m-%d %H:%M:%S |
|
247 | datefmt = %Y-%m-%d %H:%M:%S | |
242 |
|
248 | |||
243 | [formatter_color_formatter] |
|
249 | [formatter_color_formatter] | |
244 | class=rhodecode.lib.colored_formatter.ColorFormatter |
|
250 | class=rhodecode.lib.colored_formatter.ColorFormatter | |
245 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
251 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
246 | datefmt = %Y-%m-%d %H:%M:%S |
|
252 | datefmt = %Y-%m-%d %H:%M:%S | |
247 |
|
253 | |||
248 | [formatter_color_formatter_sql] |
|
254 | [formatter_color_formatter_sql] | |
249 | class=rhodecode.lib.colored_formatter.ColorFormatterSql |
|
255 | class=rhodecode.lib.colored_formatter.ColorFormatterSql | |
250 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
256 | format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s | |
251 | datefmt = %Y-%m-%d %H:%M:%S No newline at end of file |
|
257 | datefmt = %Y-%m-%d %H:%M:%S |
@@ -1,242 +1,248 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.controllers.api |
|
3 | rhodecode.controllers.api | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | JSON RPC controller |
|
6 | JSON RPC controller | |
7 |
|
7 | |||
8 | :created_on: Aug 20, 2011 |
|
8 | :created_on: Aug 20, 2011 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | |
11 | :license: GPLv3, see COPYING for more details. |
|
11 | :license: GPLv3, see COPYING for more details. | |
12 | """ |
|
12 | """ | |
13 | # This program is free software; you can redistribute it and/or |
|
13 | # This program is free software; you can redistribute it and/or | |
14 | # modify it under the terms of the GNU General Public License |
|
14 | # modify it under the terms of the GNU General Public License | |
15 | # as published by the Free Software Foundation; version 2 |
|
15 | # as published by the Free Software Foundation; version 2 | |
16 | # of the License or (at your opinion) any later version of the license. |
|
16 | # of the License or (at your opinion) any later version of the license. | |
17 | # |
|
17 | # | |
18 | # This program is distributed in the hope that it will be useful, |
|
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. |
|
21 | # GNU General Public License for more details. | |
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program; if not, write to the Free Software |
|
24 | # along with this program; if not, write to the Free Software | |
25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
26 | # MA 02110-1301, USA. |
|
26 | # MA 02110-1301, USA. | |
27 |
|
27 | |||
28 | import inspect |
|
28 | import inspect | |
29 | import logging |
|
29 | import logging | |
30 | import types |
|
30 | import types | |
31 | import urllib |
|
31 | import urllib | |
32 | import traceback |
|
32 | import traceback | |
33 |
|
33 | |||
34 | from rhodecode.lib.compat import izip_longest, json |
|
34 | from rhodecode.lib.compat import izip_longest, json | |
35 |
|
35 | |||
36 | from paste.response import replace_header |
|
36 | from paste.response import replace_header | |
37 |
|
37 | |||
38 | from pylons.controllers import WSGIController |
|
38 | from pylons.controllers import WSGIController | |
39 | from pylons.controllers.util import Response |
|
39 | ||
40 |
|
40 | |||
41 | from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ |
|
41 | from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError, \ | |
42 | HTTPBadRequest, HTTPError |
|
42 | HTTPBadRequest, HTTPError | |
43 |
|
43 | |||
44 | from rhodecode.model.db import User |
|
44 | from rhodecode.model.db import User | |
45 | from rhodecode.lib.auth import AuthUser |
|
45 | from rhodecode.lib.auth import AuthUser | |
46 |
|
46 | |||
47 | log = logging.getLogger('JSONRPC') |
|
47 | log = logging.getLogger('JSONRPC') | |
48 |
|
48 | |||
49 | class JSONRPCError(BaseException): |
|
49 | class JSONRPCError(BaseException): | |
50 |
|
50 | |||
51 | def __init__(self, message): |
|
51 | def __init__(self, message): | |
52 | self.message = message |
|
52 | self.message = message | |
53 |
|
53 | |||
54 | def __str__(self): |
|
54 | def __str__(self): | |
55 | return str(self.message) |
|
55 | return str(self.message) | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | def jsonrpc_error(message, code=None): |
|
58 | def jsonrpc_error(message, code=None): | |
59 | """Generate a Response object with a JSON-RPC error body""" |
|
59 | """ | |
60 | return Response(body=json.dumps(dict(result=None, |
|
60 | Generate a Response object with a JSON-RPC error body | |
61 | error=message))) |
|
61 | """ | |
|
62 | from pylons.controllers.util import Response | |||
|
63 | resp = Response(body=json.dumps(dict(result=None, error=message)), | |||
|
64 | status=code, | |||
|
65 | content_type='application/json') | |||
|
66 | return resp | |||
|
67 | ||||
62 |
|
68 | |||
63 |
|
69 | |||
64 | class JSONRPCController(WSGIController): |
|
70 | class JSONRPCController(WSGIController): | |
65 | """ |
|
71 | """ | |
66 | A WSGI-speaking JSON-RPC controller class |
|
72 | A WSGI-speaking JSON-RPC controller class | |
67 |
|
73 | |||
68 | See the specification: |
|
74 | See the specification: | |
69 | <http://json-rpc.org/wiki/specification>`. |
|
75 | <http://json-rpc.org/wiki/specification>`. | |
70 |
|
76 | |||
71 | Valid controller return values should be json-serializable objects. |
|
77 | Valid controller return values should be json-serializable objects. | |
72 |
|
78 | |||
73 | Sub-classes should catch their exceptions and raise JSONRPCError |
|
79 | Sub-classes should catch their exceptions and raise JSONRPCError | |
74 | if they want to pass meaningful errors to the client. |
|
80 | if they want to pass meaningful errors to the client. | |
75 |
|
81 | |||
76 | """ |
|
82 | """ | |
77 |
|
83 | |||
78 | def _get_method_args(self): |
|
84 | def _get_method_args(self): | |
79 | """ |
|
85 | """ | |
80 | Return `self._rpc_args` to dispatched controller method |
|
86 | Return `self._rpc_args` to dispatched controller method | |
81 | chosen by __call__ |
|
87 | chosen by __call__ | |
82 | """ |
|
88 | """ | |
83 | return self._rpc_args |
|
89 | return self._rpc_args | |
84 |
|
90 | |||
85 | def __call__(self, environ, start_response): |
|
91 | def __call__(self, environ, start_response): | |
86 | """ |
|
92 | """ | |
87 | Parse the request body as JSON, look up the method on the |
|
93 | Parse the request body as JSON, look up the method on the | |
88 | controller and if it exists, dispatch to it. |
|
94 | controller and if it exists, dispatch to it. | |
89 | """ |
|
95 | """ | |
90 | if 'CONTENT_LENGTH' not in environ: |
|
96 | if 'CONTENT_LENGTH' not in environ: | |
91 | log.debug("No Content-Length") |
|
97 | log.debug("No Content-Length") | |
92 | return jsonrpc_error(message="No Content-Length in request") |
|
98 | return jsonrpc_error(message="No Content-Length in request") | |
93 | else: |
|
99 | else: | |
94 | length = environ['CONTENT_LENGTH'] or 0 |
|
100 | length = environ['CONTENT_LENGTH'] or 0 | |
95 | length = int(environ['CONTENT_LENGTH']) |
|
101 | length = int(environ['CONTENT_LENGTH']) | |
96 | log.debug('Content-Length: %s', length) |
|
102 | log.debug('Content-Length: %s', length) | |
97 |
|
103 | |||
98 | if length == 0: |
|
104 | if length == 0: | |
99 | log.debug("Content-Length is 0") |
|
105 | log.debug("Content-Length is 0") | |
100 | return jsonrpc_error(message="Content-Length is 0") |
|
106 | return jsonrpc_error(message="Content-Length is 0") | |
101 |
|
107 | |||
102 | raw_body = environ['wsgi.input'].read(length) |
|
108 | raw_body = environ['wsgi.input'].read(length) | |
103 |
|
109 | |||
104 | try: |
|
110 | try: | |
105 | json_body = json.loads(urllib.unquote_plus(raw_body)) |
|
111 | json_body = json.loads(urllib.unquote_plus(raw_body)) | |
106 | except ValueError, e: |
|
112 | except ValueError, e: | |
107 | #catch JSON errors Here |
|
113 | #catch JSON errors Here | |
108 | return jsonrpc_error(message="JSON parse error ERR:%s RAW:%r" \ |
|
114 | return jsonrpc_error(message="JSON parse error ERR:%s RAW:%r" \ | |
109 | % (e, urllib.unquote_plus(raw_body))) |
|
115 | % (e, urllib.unquote_plus(raw_body))) | |
110 |
|
116 | |||
111 | #check AUTH based on API KEY |
|
117 | #check AUTH based on API KEY | |
112 | try: |
|
118 | try: | |
113 | self._req_api_key = json_body['api_key'] |
|
119 | self._req_api_key = json_body['api_key'] | |
114 | self._req_method = json_body['method'] |
|
120 | self._req_method = json_body['method'] | |
115 | self._req_params = json_body['args'] |
|
121 | self._req_params = json_body['args'] | |
116 | log.debug('method: %s, params: %s', |
|
122 | log.debug('method: %s, params: %s', | |
117 | self._req_method, |
|
123 | self._req_method, | |
118 | self._req_params) |
|
124 | self._req_params) | |
119 | except KeyError, e: |
|
125 | except KeyError, e: | |
120 | return jsonrpc_error(message='Incorrect JSON query missing %s' % e) |
|
126 | return jsonrpc_error(message='Incorrect JSON query missing %s' % e) | |
121 |
|
127 | |||
122 | #check if we can find this session using api_key |
|
128 | #check if we can find this session using api_key | |
123 | try: |
|
129 | try: | |
124 | u = User.get_by_api_key(self._req_api_key) |
|
130 | u = User.get_by_api_key(self._req_api_key) | |
125 | auth_u = AuthUser(u.user_id, self._req_api_key) |
|
131 | auth_u = AuthUser(u.user_id, self._req_api_key) | |
126 | except Exception, e: |
|
132 | except Exception, e: | |
127 | return jsonrpc_error(message='Invalid API KEY') |
|
133 | return jsonrpc_error(message='Invalid API KEY') | |
128 |
|
134 | |||
129 | self._error = None |
|
135 | self._error = None | |
130 | try: |
|
136 | try: | |
131 | self._func = self._find_method() |
|
137 | self._func = self._find_method() | |
132 | except AttributeError, e: |
|
138 | except AttributeError, e: | |
133 | return jsonrpc_error(message=str(e)) |
|
139 | return jsonrpc_error(message=str(e)) | |
134 |
|
140 | |||
135 | # now that we have a method, add self._req_params to |
|
141 | # now that we have a method, add self._req_params to | |
136 | # self.kargs and dispatch control to WGIController |
|
142 | # self.kargs and dispatch control to WGIController | |
137 | argspec = inspect.getargspec(self._func) |
|
143 | argspec = inspect.getargspec(self._func) | |
138 | arglist = argspec[0][1:] |
|
144 | arglist = argspec[0][1:] | |
139 | defaults = argspec[3] or [] |
|
145 | defaults = argspec[3] or [] | |
140 | default_empty = types.NotImplementedType |
|
146 | default_empty = types.NotImplementedType | |
141 |
|
147 | |||
142 | kwarglist = list(izip_longest(reversed(arglist), reversed(defaults), |
|
148 | kwarglist = list(izip_longest(reversed(arglist), reversed(defaults), | |
143 | fillvalue=default_empty)) |
|
149 | fillvalue=default_empty)) | |
144 |
|
150 | |||
145 | # this is little trick to inject logged in user for |
|
151 | # this is little trick to inject logged in user for | |
146 | # perms decorators to work they expect the controller class to have |
|
152 | # perms decorators to work they expect the controller class to have | |
147 | # rhodecode_user attribute set |
|
153 | # rhodecode_user attribute set | |
148 | self.rhodecode_user = auth_u |
|
154 | self.rhodecode_user = auth_u | |
149 |
|
155 | |||
150 | # This attribute will need to be first param of a method that uses |
|
156 | # This attribute will need to be first param of a method that uses | |
151 | # api_key, which is translated to instance of user at that name |
|
157 | # api_key, which is translated to instance of user at that name | |
152 | USER_SESSION_ATTR = 'apiuser' |
|
158 | USER_SESSION_ATTR = 'apiuser' | |
153 |
|
159 | |||
154 | if USER_SESSION_ATTR not in arglist: |
|
160 | if USER_SESSION_ATTR not in arglist: | |
155 | return jsonrpc_error(message='This method [%s] does not support ' |
|
161 | return jsonrpc_error(message='This method [%s] does not support ' | |
156 | 'authentication (missing %s param)' % |
|
162 | 'authentication (missing %s param)' % | |
157 | (self._func.__name__, USER_SESSION_ATTR)) |
|
163 | (self._func.__name__, USER_SESSION_ATTR)) | |
158 |
|
164 | |||
159 | # get our arglist and check if we provided them as args |
|
165 | # get our arglist and check if we provided them as args | |
160 | for arg, default in kwarglist: |
|
166 | for arg, default in kwarglist: | |
161 | if arg == USER_SESSION_ATTR: |
|
167 | if arg == USER_SESSION_ATTR: | |
162 | # USER_SESSION_ATTR is something translated from api key and |
|
168 | # USER_SESSION_ATTR is something translated from api key and | |
163 | # this is checked before so we don't need validate it |
|
169 | # this is checked before so we don't need validate it | |
164 | continue |
|
170 | continue | |
165 |
|
171 | |||
166 | # skip the required param check if it's default value is |
|
172 | # skip the required param check if it's default value is | |
167 | # NotImplementedType (default_empty) |
|
173 | # NotImplementedType (default_empty) | |
168 | if not self._req_params or (type(default) == default_empty |
|
174 | if not self._req_params or (type(default) == default_empty | |
169 | and arg not in self._req_params): |
|
175 | and arg not in self._req_params): | |
170 | return jsonrpc_error(message=('Missing non optional %s arg ' |
|
176 | return jsonrpc_error(message=('Missing non optional %s arg ' | |
171 | 'in JSON DATA') % arg) |
|
177 | 'in JSON DATA') % arg) | |
172 |
|
178 | |||
173 | self._rpc_args = {USER_SESSION_ATTR:u} |
|
179 | self._rpc_args = {USER_SESSION_ATTR:u} | |
174 | self._rpc_args.update(self._req_params) |
|
180 | self._rpc_args.update(self._req_params) | |
175 |
|
181 | |||
176 | self._rpc_args['action'] = self._req_method |
|
182 | self._rpc_args['action'] = self._req_method | |
177 | self._rpc_args['environ'] = environ |
|
183 | self._rpc_args['environ'] = environ | |
178 | self._rpc_args['start_response'] = start_response |
|
184 | self._rpc_args['start_response'] = start_response | |
179 |
|
185 | |||
180 | status = [] |
|
186 | status = [] | |
181 | headers = [] |
|
187 | headers = [] | |
182 | exc_info = [] |
|
188 | exc_info = [] | |
183 | def change_content(new_status, new_headers, new_exc_info=None): |
|
189 | def change_content(new_status, new_headers, new_exc_info=None): | |
184 | status.append(new_status) |
|
190 | status.append(new_status) | |
185 | headers.extend(new_headers) |
|
191 | headers.extend(new_headers) | |
186 | exc_info.append(new_exc_info) |
|
192 | exc_info.append(new_exc_info) | |
187 |
|
193 | |||
188 | output = WSGIController.__call__(self, environ, change_content) |
|
194 | output = WSGIController.__call__(self, environ, change_content) | |
189 | output = list(output) |
|
195 | output = list(output) | |
190 | headers.append(('Content-Length', str(len(output[0])))) |
|
196 | headers.append(('Content-Length', str(len(output[0])))) | |
191 | replace_header(headers, 'Content-Type', 'application/json') |
|
197 | replace_header(headers, 'Content-Type', 'application/json') | |
192 | start_response(status[0], headers, exc_info[0]) |
|
198 | start_response(status[0], headers, exc_info[0]) | |
193 |
|
199 | |||
194 | return output |
|
200 | return output | |
195 |
|
201 | |||
196 | def _dispatch_call(self): |
|
202 | def _dispatch_call(self): | |
197 | """ |
|
203 | """ | |
198 | Implement dispatch interface specified by WSGIController |
|
204 | Implement dispatch interface specified by WSGIController | |
199 | """ |
|
205 | """ | |
200 | try: |
|
206 | try: | |
201 | raw_response = self._inspect_call(self._func) |
|
207 | raw_response = self._inspect_call(self._func) | |
202 | if isinstance(raw_response, HTTPError): |
|
208 | if isinstance(raw_response, HTTPError): | |
203 | self._error = str(raw_response) |
|
209 | self._error = str(raw_response) | |
204 | except JSONRPCError, e: |
|
210 | except JSONRPCError, e: | |
205 | self._error = str(e) |
|
211 | self._error = str(e) | |
206 | except Exception, e: |
|
212 | except Exception, e: | |
207 | log.error('Encountered unhandled exception: %s' \ |
|
213 | log.error('Encountered unhandled exception: %s' \ | |
208 | % traceback.format_exc()) |
|
214 | % traceback.format_exc()) | |
209 | json_exc = JSONRPCError('Internal server error') |
|
215 | json_exc = JSONRPCError('Internal server error') | |
210 | self._error = str(json_exc) |
|
216 | self._error = str(json_exc) | |
211 |
|
217 | |||
212 | if self._error is not None: |
|
218 | if self._error is not None: | |
213 | raw_response = None |
|
219 | raw_response = None | |
214 |
|
220 | |||
215 | response = dict(result=raw_response, error=self._error) |
|
221 | response = dict(result=raw_response, error=self._error) | |
216 |
|
222 | |||
217 | try: |
|
223 | try: | |
218 | return json.dumps(response) |
|
224 | return json.dumps(response) | |
219 | except TypeError, e: |
|
225 | except TypeError, e: | |
220 | log.debug('Error encoding response: %s', e) |
|
226 | log.debug('Error encoding response: %s', e) | |
221 | return json.dumps(dict(result=None, |
|
227 | return json.dumps(dict(result=None, | |
222 | error="Error encoding response")) |
|
228 | error="Error encoding response")) | |
223 |
|
229 | |||
224 | def _find_method(self): |
|
230 | def _find_method(self): | |
225 | """ |
|
231 | """ | |
226 | Return method named by `self._req_method` in controller if able |
|
232 | Return method named by `self._req_method` in controller if able | |
227 | """ |
|
233 | """ | |
228 | log.debug('Trying to find JSON-RPC method: %s', self._req_method) |
|
234 | log.debug('Trying to find JSON-RPC method: %s', self._req_method) | |
229 | if self._req_method.startswith('_'): |
|
235 | if self._req_method.startswith('_'): | |
230 | raise AttributeError("Method not allowed") |
|
236 | raise AttributeError("Method not allowed") | |
231 |
|
237 | |||
232 | try: |
|
238 | try: | |
233 | func = getattr(self, self._req_method, None) |
|
239 | func = getattr(self, self._req_method, None) | |
234 | except UnicodeEncodeError: |
|
240 | except UnicodeEncodeError: | |
235 | raise AttributeError("Problem decoding unicode in requested " |
|
241 | raise AttributeError("Problem decoding unicode in requested " | |
236 | "method name.") |
|
242 | "method name.") | |
237 |
|
243 | |||
238 | if isinstance(func, types.MethodType): |
|
244 | if isinstance(func, types.MethodType): | |
239 | return func |
|
245 | return func | |
240 | else: |
|
246 | else: | |
241 | raise AttributeError("No such method: %s" % self._req_method) |
|
247 | raise AttributeError("No such method: %s" % self._req_method) | |
242 |
|
248 |
General Comments 0
You need to be logged in to leave comments.
Login now