Show More
@@ -76,25 +76,26 b' class RhodecodeCeleryTask(Task):' | |||||
76 |
|
76 | |||
77 | request = get_current_request() |
|
77 | request = get_current_request() | |
78 |
|
78 | |||
79 | # we hook into kwargs since it is the only way to pass our data to the |
|
79 | if request: | |
80 | # celery worker in celery 2.2 |
|
80 | # we hook into kwargs since it is the only way to pass our data to | |
81 | kwargs.update({ |
|
81 | # the celery worker in celery 2.2 | |
82 | '_rhodecode_proxy_data': { |
|
82 | kwargs.update({ | |
83 |
' |
|
83 | '_rhodecode_proxy_data': { | |
84 |
' |
|
84 | 'environ': { | |
85 |
' |
|
85 | 'PATH_INFO': request.environ['PATH_INFO'], | |
86 |
' |
|
86 | 'SCRIPT_NAME': request.environ['SCRIPT_NAME'], | |
87 |
request.environ |
|
87 | 'HTTP_HOST': request.environ.get('HTTP_HOST', | |
88 |
|
|
88 | request.environ['SERVER_NAME']), | |
89 |
'SERVER_ |
|
89 | 'SERVER_NAME': request.environ['SERVER_NAME'], | |
90 |
' |
|
90 | 'SERVER_PORT': request.environ['SERVER_PORT'], | |
91 | }, |
|
91 | 'wsgi.url_scheme': request.environ['wsgi.url_scheme'], | |
92 |
|
|
92 | }, | |
93 |
' |
|
93 | 'auth_user': { | |
94 |
' |
|
94 | 'ip_addr': request.user.ip_addr, | |
95 | }, |
|
95 | 'user_id': request.user.user_id | |
96 | } |
|
96 | }, | |
97 |
} |
|
97 | } | |
|
98 | }) | |||
98 | return super(RhodecodeCeleryTask, self).apply_async( |
|
99 | return super(RhodecodeCeleryTask, self).apply_async( | |
99 | args, kwargs, task_id, producer, link, link_error, **options) |
|
100 | args, kwargs, task_id, producer, link, link_error, **options) | |
100 |
|
101 |
@@ -18,15 +18,16 b'' | |||||
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
|
21 | import rhodecode | |||
|
22 | from pylons import config | |||
|
23 | ||||
21 | from celery.loaders.base import BaseLoader |
|
24 | from celery.loaders.base import BaseLoader | |
22 | from pylons import config |
|
|||
23 |
|
25 | |||
24 | to_pylons = lambda x: x.replace('_', '.').lower() |
|
26 | to_pylons = lambda x: x.replace('_', '.').lower() | |
25 | to_celery = lambda x: x.replace('.', '_').upper() |
|
27 | to_celery = lambda x: x.replace('.', '_').upper() | |
26 |
|
28 | |||
27 | LIST_PARAMS = """CELERY_IMPORTS ADMINS ROUTES""".split() |
|
29 | LIST_PARAMS = """CELERY_IMPORTS ADMINS ROUTES""".split() | |
28 |
|
30 | |||
29 |
|
||||
30 | class PylonsSettingsProxy(object): |
|
31 | class PylonsSettingsProxy(object): | |
31 | """Pylons Settings Proxy |
|
32 | """Pylons Settings Proxy | |
32 |
|
33 | |||
@@ -36,7 +37,7 b' class PylonsSettingsProxy(object):' | |||||
36 | def __getattr__(self, key): |
|
37 | def __getattr__(self, key): | |
37 | pylons_key = to_pylons(key) |
|
38 | pylons_key = to_pylons(key) | |
38 | try: |
|
39 | try: | |
39 |
value = |
|
40 | value = rhodecode.PYRAMID_SETTINGS[pylons_key] | |
40 | if key in LIST_PARAMS:return value.split() |
|
41 | if key in LIST_PARAMS:return value.split() | |
41 | return self.type_converter(value) |
|
42 | return self.type_converter(value) | |
42 | except KeyError: |
|
43 | except KeyError: | |
@@ -56,7 +57,7 b' class PylonsSettingsProxy(object):' | |||||
56 |
|
57 | |||
57 | def __setattr__(self, key, value): |
|
58 | def __setattr__(self, key, value): | |
58 | pylons_key = to_pylons(key) |
|
59 | pylons_key = to_pylons(key) | |
59 |
|
|
60 | rhodecode.PYRAMID_SETTINGS[pylons_key] = value | |
60 |
|
61 | |||
61 | def __setitem__(self, key, value): |
|
62 | def __setitem__(self, key, value): | |
62 | self.__setattr__(key, value) |
|
63 | self.__setattr__(key, value) |
General Comments 0
You need to be logged in to leave comments.
Login now