subscribers: optimized used of threadglobals and fix python3 compat
This commit is contained in:
parent
1ad7107b99
commit
c59d44237d
1 changed files with 4 additions and 4 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2010-2020 RhodeCode GmbH
|
||||
#
|
||||
|
|
@ -30,7 +29,6 @@ import subprocess
|
|||
|
||||
|
||||
from dateutil.parser import parse
|
||||
from pyramid.threadlocal import get_current_request
|
||||
from pyramid.interfaces import IRoutesMapper
|
||||
from pyramid.settings import asbool
|
||||
from pyramid.path import AssetResolver
|
||||
|
|
@ -38,6 +36,7 @@ from threading import Thread
|
|||
|
||||
from rhodecode.config.jsroutes import generate_jsroutes_content
|
||||
from rhodecode.lib.base import get_auth_user
|
||||
from rhodecode.lib.celerylib.loader import set_celery_conf
|
||||
|
||||
import rhodecode
|
||||
|
||||
|
|
@ -50,6 +49,7 @@ def add_renderer_globals(event):
|
|||
|
||||
# TODO: When executed in pyramid view context the request is not available
|
||||
# in the event. Find a better solution to get the request.
|
||||
from pyramid.threadlocal import get_current_request
|
||||
request = event['request'] or get_current_request()
|
||||
|
||||
# Add Pyramid translation as '_' to context
|
||||
|
|
@ -70,7 +70,6 @@ def set_user_lang(event):
|
|||
|
||||
|
||||
def update_celery_conf(event):
|
||||
from rhodecode.lib.celerylib.loader import set_celery_conf
|
||||
log.debug('Setting celery config from new request')
|
||||
set_celery_conf(request=event.request, registry=event.request.registry)
|
||||
|
||||
|
|
@ -79,6 +78,7 @@ def add_request_user_context(event):
|
|||
"""
|
||||
Adds auth user into request context
|
||||
"""
|
||||
|
||||
request = event.request
|
||||
# access req_id as soon as possible
|
||||
req_id = request.req_id
|
||||
|
|
@ -307,7 +307,7 @@ def write_js_routes_if_enabled(event):
|
|||
static_path, 'js', 'rhodecode', 'routes.js')
|
||||
|
||||
try:
|
||||
with io.open(jsroutes_file_path, 'w', encoding='utf-8') as f:
|
||||
with open(jsroutes_file_path, 'w', encoding='utf-8') as f:
|
||||
f.write(jsroutes_file_content)
|
||||
except Exception:
|
||||
log.exception('Failed to write routes.js into %s', jsroutes_file_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue