app/soc/views/sitemap/sidebar.py
changeset 697 190b65431579
parent 637 86ec079d8302
child 703 c4f3997becd9
--- a/app/soc/views/sitemap/sidebar.py	Sun Dec 07 13:38:53 2008 +0000
+++ b/app/soc/views/sitemap/sidebar.py	Sun Dec 07 13:49:22 2008 +0000
@@ -30,17 +30,24 @@
 
 
 def addMenu(callback):
+  """Adds a callback to the menu builder.
+
+  The callback should return a list of menu's when called.
+  """
+
   global SIDEBAR
   SIDEBAR.append(callback)
 
 def getSidebar(request):
+  """Constructs a sidebar for the specified request
+  """
+
   sidebar = []
 
   for callback in SIDEBAR:
-    menu = callback(request)
-    
-    if menu:
-      # only if there is a menu we should append it
+    menus = callback(request)
+
+    for menu in (menus if menus else []):
       sidebar.append(menu)
 
   return sidebar
@@ -129,12 +136,14 @@
   if not items:
     return
 
-  res = {}
+  menu = {}
 
   if 'sidebar_heading' not in params:
     params['sidebar_heading'] = params['name']
 
-  res['heading'] = params['sidebar_heading']
-  res['items'] = items
+  menu['heading'] = params['sidebar_heading']
+  menu['items'] = items
 
-  return res
+  menus = [menu]
+
+  return menus