Do not pass around request anymore in buildSidebar
It is no longer needed since checkAccess doesn't require it.
Patch by: Sverre Rabbelier
--- a/app/soc/views/helper/responses.py Sun Jan 25 00:02:41 2009 +0000
+++ b/app/soc/views/helper/responses.py Sun Jan 25 00:04:11 2009 +0000
@@ -108,7 +108,7 @@
context['is_debug'] = system.isDebug()
context['sign_in'] = users.create_login_url(request.path)
context['sign_out'] = users.create_logout_url(request.path)
- context['sidebar_menu_items'] = sidebar.getSidebar(request)
+ context['sidebar_menu_items'] = sidebar.getSidebar()
context['soc_release'] = release.RELEASE_TAG
context['gae_version'] = system.getAppVersion()
--- a/app/soc/views/models/base.py Sun Jan 25 00:02:41 2009 +0000
+++ b/app/soc/views/models/base.py Sun Jan 25 00:04:11 2009 +0000
@@ -707,11 +707,10 @@
return self._params
@decorators.merge_params
- def getSidebarMenus(self, request, params=None):
+ def getSidebarMenus(self, params=None):
"""Returns an dictionary with one sidebar entry.
Args:
- request: the django request object
params: a dict with params for this View
Params usage:
@@ -720,7 +719,7 @@
of _getSidebarItems on how it uses it.
"""
- return sitemap.sidebar.getSidebarMenus(request, params)
+ return sitemap.sidebar.getSidebarMenus(params=params)
@decorators.merge_params
def getDjangoURLPatterns(self, params=None):
--- a/app/soc/views/models/program.py Sun Jan 25 00:02:41 2009 +0000
+++ b/app/soc/views/models/program.py Sun Jan 25 00:04:11 2009 +0000
@@ -116,7 +116,7 @@
timeline = timeline_logic.updateOrCreateFromFields(properties, properties)
return timeline
- def getExtraMenus(self, request, params=None):
+ def getExtraMenus(self, params=None):
"""Returns the extra menu's for this view.
A menu item is generated for each program that is currently
@@ -124,7 +124,6 @@
as well as all public documents for that program.
Args:
- request: unused
params: a dict with params for this View.
"""
@@ -140,7 +139,7 @@
menu = {}
menu['heading'] = entity.short_name
items = document_view.view.getMenusForScope(entity, params)
- menu['items'] = sidebar.getSidebarMenu(request, items, params=doc_params)
+ menu['items'] = sidebar.getSidebarMenu(items, params=doc_params)
menus.append(menu)
return menus
--- a/app/soc/views/models/site.py Sun Jan 25 00:02:41 2009 +0000
+++ b/app/soc/views/models/site.py Sun Jan 25 00:04:11 2009 +0000
@@ -87,7 +87,7 @@
super(View, self).__init__(params=params)
- def getSidebarMenus(self, request, params=None):
+ def getSidebarMenus(self, params=None):
"""See base.View.getSidebarMenus.
Returns a custom sidebar entry for the 'site' singleton.
@@ -104,7 +104,7 @@
new_params['sidebar_additional'] = submenus
params = dicts.merge(params, new_params)
- return super(View, self).getSidebarMenus(request, params=params)
+ return super(View, self).getSidebarMenus(params=params)
def mainPublic(self, request, page_name=None, **kwargs):
"""Displays the main site settings page.
--- a/app/soc/views/models/user_self.py Sun Jan 25 00:02:41 2009 +0000
+++ b/app/soc/views/models/user_self.py Sun Jan 25 00:04:11 2009 +0000
@@ -252,7 +252,7 @@
super(View, self)._editPost(request, entity, fields)
- def getSidebarMenus(self, request, params=None):
+ def getSidebarMenus(self, params=None):
"""See base.View.getSidebarMenus().
"""
@@ -279,7 +279,7 @@
params = dicts.merge(params, new_params)
- return super(View, self).getSidebarMenus(request, params=params)
+ return super(View, self).getSidebarMenus(params=params)
view = View()
--- a/app/soc/views/sitemap/sidebar.py Sun Jan 25 00:02:41 2009 +0000
+++ b/app/soc/views/sitemap/sidebar.py Sun Jan 25 00:04:11 2009 +0000
@@ -40,14 +40,14 @@
global SIDEBAR
SIDEBAR.append(callback)
-def getSidebar(request):
- """Constructs a sidebar for the specified request.
+def getSidebar():
+ """Constructs a sidebar for the current user.
"""
sidebar = []
for callback in SIDEBAR:
- menus = callback(request)
+ menus = callback()
for menu in (menus if menus else []):
sidebar.append(menu)
@@ -98,7 +98,7 @@
return result
-def getSidebarMenu(request, items, params):
+def getSidebarMenu(items, params):
"""Returns an dictionary with one sidebar entry.
Items is expected to be a tuple with an url, a menu_text, and an
@@ -106,7 +106,6 @@
raises out_of_band.Error, the item will not be added.
Args:
- request: the django request object
items: see above
params: a dict with params for this View
@@ -145,7 +144,7 @@
return submenus
-def getSidebarMenus(request, params=None):
+def getSidebarMenus(params=None):
"""Constructs the default sidebar menu for a View.
Calls getSidebarItems to retrieve the items that should be in the
@@ -153,12 +152,11 @@
docstrings for an explanation on what they do.
Args:
- request: the django request object
params: a dict with params for this View
"""
items = getSidebarItems(params)
- submenus = getSidebarMenu(request, items, params)
+ submenus = getSidebarMenu(items, params)
if not submenus:
return