Show More
@@ -254,7 +254,11 b' class BasicAuth(AuthBasicAuthenticator):' | |||
|
254 | 254 | __call__ = authenticate |
|
255 | 255 | |
|
256 | 256 | |
|
257 | def attach_context_attributes(context): | |
|
257 | def attach_context_attributes(context, request): | |
|
258 | """ | |
|
259 | Attach variables into template context called `c`, please note that | |
|
260 | request could be pylons or pyramid request in here. | |
|
261 | """ | |
|
258 | 262 | rc_config = SettingsModel().get_all_settings(cache=True) |
|
259 | 263 | |
|
260 | 264 | context.rhodecode_version = rhodecode.__version__ |
@@ -320,6 +324,35 b' def attach_context_attributes(context):' | |||
|
320 | 324 | 'appenlight.api_public_key', '') |
|
321 | 325 | context.appenlight_server_url = config.get('appenlight.server_url', '') |
|
322 | 326 | |
|
327 | # JS template context | |
|
328 | context.template_context = { | |
|
329 | 'repo_name': None, | |
|
330 | 'repo_type': None, | |
|
331 | 'repo_landing_commit': None, | |
|
332 | 'rhodecode_user': { | |
|
333 | 'username': None, | |
|
334 | 'email': None, | |
|
335 | }, | |
|
336 | 'visual': { | |
|
337 | 'default_renderer': None | |
|
338 | }, | |
|
339 | 'commit_data': { | |
|
340 | 'commit_id': None | |
|
341 | }, | |
|
342 | 'pull_request_data': {'pull_request_id': None}, | |
|
343 | 'timeago': { | |
|
344 | 'refresh_time': 120 * 1000, | |
|
345 | 'cutoff_limit': 1000 * 60 * 60 * 24 * 7 | |
|
346 | }, | |
|
347 | 'pylons_dispatch': { | |
|
348 | # 'controller': request.environ['pylons.routes_dict']['controller'], | |
|
349 | # 'action': request.environ['pylons.routes_dict']['action'], | |
|
350 | }, | |
|
351 | 'pyramid_dispatch': { | |
|
352 | ||
|
353 | }, | |
|
354 | 'extra': {'plugins': {}} | |
|
355 | } | |
|
323 | 356 | # END CONFIG VARS |
|
324 | 357 | |
|
325 | 358 | # TODO: This dosn't work when called from pylons compatibility tween. |
@@ -380,7 +413,7 b' class BaseController(WSGIController):' | |||
|
380 | 413 | """ |
|
381 | 414 | # on each call propagate settings calls into global settings. |
|
382 | 415 | set_rhodecode_config(config) |
|
383 | attach_context_attributes(c) | |
|
416 | attach_context_attributes(c, request) | |
|
384 | 417 | |
|
385 | 418 | # TODO: Remove this when fixed in attach_context_attributes() |
|
386 | 419 | c.repo_name = get_repo_slug(request) # can be empty |
@@ -425,32 +458,6 b' class BaseController(WSGIController):' | |||
|
425 | 458 | _route_name = '.'.join([environ['pylons.routes_dict']['controller'], |
|
426 | 459 | environ['pylons.routes_dict']['action']]) |
|
427 | 460 | |
|
428 | c.template_context = { | |
|
429 | 'repo_name': None, | |
|
430 | 'repo_type': None, | |
|
431 | 'repo_landing_commit': None, | |
|
432 | 'rhodecode_user': { | |
|
433 | 'username': None, | |
|
434 | 'email': None, | |
|
435 | }, | |
|
436 | 'visual': { | |
|
437 | 'default_renderer': None | |
|
438 | }, | |
|
439 | 'commit_data': { | |
|
440 | 'commit_id': None | |
|
441 | }, | |
|
442 | 'pull_request_data': {'pull_request_id': None}, | |
|
443 | 'timeago': { | |
|
444 | 'refresh_time': 120 * 1000, | |
|
445 | 'cutoff_limit': 1000*60*60*24*7 | |
|
446 | }, | |
|
447 | 'pylons_dispatch':{ | |
|
448 | 'controller': environ['pylons.routes_dict']['controller'], | |
|
449 | 'action': environ['pylons.routes_dict']['action'], | |
|
450 | }, | |
|
451 | 'extra': {'plugins': {}} | |
|
452 | } | |
|
453 | ||
|
454 | 461 | self.rc_config = SettingsModel().get_all_settings(cache=True) |
|
455 | 462 | self.ip_addr = get_ip_addr(environ) |
|
456 | 463 |
@@ -67,7 +67,7 b' def pylons_compatibility_tween_factory(h' | |||
|
67 | 67 | # Setup the pylons context object ('c') |
|
68 | 68 | context = ContextObj() |
|
69 | 69 | context.rhodecode_user = auth_user |
|
70 | attach_context_attributes(context) | |
|
70 | attach_context_attributes(context, request) | |
|
71 | 71 | pylons.tmpl_context._push_object(context) |
|
72 | 72 | return handler(request) |
|
73 | 73 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now