Use the per-request store to store the context
authorSverre Rabbelier <srabbelier@gmail.com>
Fri, 28 Aug 2009 11:48:27 -0700
changeset 2835 aff661c7f936
parent 2834 03a1602c63f1
child 2836 0181649aa7b0
Use the per-request store to store the context
app/soc/views/helper/responses.py
--- a/app/soc/views/helper/responses.py	Fri Aug 28 11:47:32 2009 -0700
+++ b/app/soc/views/helper/responses.py	Fri Aug 28 11:48:27 2009 -0700
@@ -106,11 +106,17 @@
     }
   """
 
+  core = callback.getCore()
+
+  context = core.getRequestValue('context', {})
+
+  if context:
+    return context
+
   account = accounts.getCurrentAccount()
   user = None
   is_admin = False
 
-  context = {}
   context['request'] = request
 
   if account:
@@ -126,7 +132,7 @@
   context['sign_in'] = users.create_login_url(request.path)
   context['sign_out'] = users.create_logout_url(request.path)
 
-  context['sidebar_menu_items'] = callback.getCore().getSidebar(account, user)
+  context['sidebar_menu_items'] = core.getSidebar(account, user)
 
   context['gae_version'] = system.getAppVersion()
   context['soc_release'] = system.getMelangeVersion()
@@ -140,6 +146,8 @@
   context['tos_link'] = redirects.getToSRedirect(settings)
   context['in_maintenance'] = timeline.isActivePeriod(site, 'maintenance')
  
+  core.setRequestValue('context', context)
+
   return context
 
 def useJavaScript(context, uses):