diff options
author | Gabriel Hurley <gabriel@strikeawe.com> | 2012-03-13 15:09:12 -0700 |
---|---|---|
committer | Gabriel Hurley <gabriel@strikeawe.com> | 2012-03-13 15:11:06 -0700 |
commit | 382a5105c44ced79801b450e485e94acae39a7e0 (patch) | |
tree | f3bf10e746f2ef5bd71a51e707a72ca34e18ef08 /horizon/context_processors.py | |
parent | d3f25525474022f6e4b3601bdf9a625fa6e7ca96 (diff) | |
download | horizon-382a5105c44ced79801b450e485e94acae39a7e0.tar.gz |
User.authorized_tenants is now a cached property.
This allows moving the call to get authorized tenants out of
the middleware (which was a wasteful call on many requests),
and allows the value to be re-used anytime it's accessed more
than once per request.
Fixes bug 942074.
Change-Id: Ic09b15adbffb16c0358bb28aec73345cc01834ad
Diffstat (limited to 'horizon/context_processors.py')
-rw-r--r-- | horizon/context_processors.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/horizon/context_processors.py b/horizon/context_processors.py index 843588e6c..8b094e5e2 100644 --- a/horizon/context_processors.py +++ b/horizon/context_processors.py @@ -56,7 +56,9 @@ def horizon(request): # Auth/Keystone context context.setdefault('authorized_tenants', []) - if request.user.is_authenticated(): + current_dash = request.horizon['dashboard'] + needs_tenants = getattr(current_dash, 'supports_tenants', False) + if request.user.is_authenticated() and needs_tenants: context['authorized_tenants'] = request.user.authorized_tenants # Region context/support |