From 41cafab139a3ac585322b713f4a435857a1e1aea Mon Sep 17 00:00:00 2001 From: Marcin Kuzminski Date: Sat, 8 Jul 2017 15:25:54 +0200 Subject: [PATCH] core: always attach pyramid context into request - this will be the default way of replacing tempalte_context globals from pylons - helps remove of old style PartialRenderer --- rhodecode/api/__init__.py | 4 ++-- rhodecode/lib/base.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/rhodecode/api/__init__.py b/rhodecode/api/__init__.py index 4b6b6883..446e6bb0 100644 --- a/rhodecode/api/__init__.py +++ b/rhodecode/api/__init__.py @@ -281,8 +281,8 @@ def request_view(request): }) # register some common functions for usage - attach_context_attributes(TemplateArgs(), request, request.rpc_user.user_id, - attach_to_request=True) + attach_context_attributes( + TemplateArgs(), request, request.rpc_user.user_id) try: ret_value = func(**call_params) diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py index 48c4ef3b..112917d6 100644 --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -265,13 +265,13 @@ class BasicAuth(AuthBasicAuthenticator): __call__ = authenticate -def attach_context_attributes(context, request, user_id, attach_to_request=False): def calculate_version_hash(): return md5( config.get('beaker.session.secret', '') + rhodecode.__version__)[:8] +def attach_context_attributes(context, request, user_id): """ Attach variables into template context called `c`, please note that request could be pylons or pyramid request in here. @@ -397,11 +397,10 @@ def calculate_version_hash(): context.backends = rhodecode.BACKENDS.keys() context.backends.sort() context.unread_notifications = NotificationModel().get_unread_cnt_for_user(user_id) - if attach_to_request: - request.call_context = context - else: - context.pyramid_request = pyramid.threadlocal.get_current_request() + context.pyramid_request = pyramid.threadlocal.get_current_request() + # attach the whole call context to the request + request.call_context = context def get_auth_user(environ):