##// END OF EJS Templates
subscribers: optimized used of threadglobals and fix python3 compat
super-admin -
r5062:0a4c1892 default
parent child Browse files
Show More
@@ -1,4 +1,3 b''
1 # -*- coding: utf-8 -*-
2
1
3 # Copyright (C) 2010-2020 RhodeCode GmbH
2 # Copyright (C) 2010-2020 RhodeCode GmbH
4 #
3 #
@@ -30,7 +29,6 b' import subprocess'
30
29
31
30
32 from dateutil.parser import parse
31 from dateutil.parser import parse
33 from pyramid.threadlocal import get_current_request
34 from pyramid.interfaces import IRoutesMapper
32 from pyramid.interfaces import IRoutesMapper
35 from pyramid.settings import asbool
33 from pyramid.settings import asbool
36 from pyramid.path import AssetResolver
34 from pyramid.path import AssetResolver
@@ -38,6 +36,7 b' from threading import Thread'
38
36
39 from rhodecode.config.jsroutes import generate_jsroutes_content
37 from rhodecode.config.jsroutes import generate_jsroutes_content
40 from rhodecode.lib.base import get_auth_user
38 from rhodecode.lib.base import get_auth_user
39 from rhodecode.lib.celerylib.loader import set_celery_conf
41
40
42 import rhodecode
41 import rhodecode
43
42
@@ -50,6 +49,7 b' def add_renderer_globals(event):'
50
49
51 # TODO: When executed in pyramid view context the request is not available
50 # TODO: When executed in pyramid view context the request is not available
52 # in the event. Find a better solution to get the request.
51 # in the event. Find a better solution to get the request.
52 from pyramid.threadlocal import get_current_request
53 request = event['request'] or get_current_request()
53 request = event['request'] or get_current_request()
54
54
55 # Add Pyramid translation as '_' to context
55 # Add Pyramid translation as '_' to context
@@ -70,7 +70,6 b' def set_user_lang(event):'
70
70
71
71
72 def update_celery_conf(event):
72 def update_celery_conf(event):
73 from rhodecode.lib.celerylib.loader import set_celery_conf
74 log.debug('Setting celery config from new request')
73 log.debug('Setting celery config from new request')
75 set_celery_conf(request=event.request, registry=event.request.registry)
74 set_celery_conf(request=event.request, registry=event.request.registry)
76
75
@@ -79,6 +78,7 b' def add_request_user_context(event):'
79 """
78 """
80 Adds auth user into request context
79 Adds auth user into request context
81 """
80 """
81
82 request = event.request
82 request = event.request
83 # access req_id as soon as possible
83 # access req_id as soon as possible
84 req_id = request.req_id
84 req_id = request.req_id
@@ -307,7 +307,7 b' def write_js_routes_if_enabled(event):'
307 static_path, 'js', 'rhodecode', 'routes.js')
307 static_path, 'js', 'rhodecode', 'routes.js')
308
308
309 try:
309 try:
310 with io.open(jsroutes_file_path, 'w', encoding='utf-8') as f:
310 with open(jsroutes_file_path, 'w', encoding='utf-8') as f:
311 f.write(jsroutes_file_content)
311 f.write(jsroutes_file_content)
312 except Exception:
312 except Exception:
313 log.exception('Failed to write routes.js into %s', jsroutes_file_path)
313 log.exception('Failed to write routes.js into %s', jsroutes_file_path)
General Comments 0
You need to be logged in to leave comments. Login now