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
This commit is contained in:
parent
2489c0ed51
commit
41cafab139
2 changed files with 6 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue