summaryrefslogtreecommitdiff
path: root/horizon/tabs
diff options
context:
space:
mode:
authorGabriel Hurley <gabriel@strikeawe.com>2012-03-19 16:31:40 -0700
committerGabriel Hurley <gabriel@strikeawe.com>2012-03-19 16:31:40 -0700
commit8b1d02859612c6b3979861df8bd1e3abc053538c (patch)
tree2beea5006d07485a120cc793cb46ecc405481a62 /horizon/tabs
parent9931748ae86c50a19a9a0b74efaef8cccc568853 (diff)
downloadhorizon-8b1d02859612c6b3979861df8bd1e3abc053538c.tar.gz
Load tab context data during init for "preload" tabs. Fixes bug 959800.
Change-Id: If05c022def2e97bbae682db65d4311b1401e850d
Diffstat (limited to 'horizon/tabs')
-rw-r--r--horizon/tabs/base.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/horizon/tabs/base.py b/horizon/tabs/base.py
index 17a5a535a..12ade1986 100644
--- a/horizon/tabs/base.py
+++ b/horizon/tabs/base.py
@@ -95,6 +95,10 @@ class TabGroup(html.HTMLElement):
self._tabs = SortedDict(tab_instances)
if not self._set_active_tab():
self.tabs_not_available()
+ # Preload all data that will be loaded to allow errors to be displayed
+ for tab in self._tabs.values():
+ if tab.load:
+ tab._context_data = tab.get_context_data(request)
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self.slug)
@@ -249,6 +253,12 @@ class Tab(html.HTMLElement):
load_preloaded = self.preload or self.is_active()
return load_preloaded and self._allowed and self._enabled
+ @property
+ def context_data(self):
+ if not getattr(self, "_context_data", None):
+ self._context_data = self.get_context_data(self.request)
+ return self._context_data
+
def render(self):
"""
Renders the tab to HTML using the :meth:`~horizon.tabs.Tab.get_data`
@@ -263,7 +273,7 @@ class Tab(html.HTMLElement):
if not self.load:
return ''
try:
- context = self.get_context_data(self.request)
+ context = self.context_data
except exceptions.Http302:
raise
except: