[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container - adding.py:1.6

Tim Peters tim.one@comcast.net
Tue, 4 Mar 2003 11:28:52 -0500


Update of /cvs-repository/Zope3/src/zope/app/browser/container
In directory cvs.zope.org:/tmp/cvs-serv668/src/zope/app/browser/container

Modified Files:
	adding.py 
Log Message:
addingInfo():  Sort menu entries by title (primary) and description
(secondary).  This adds some human-friendly ordering to the list of
available items on the UI screens for adding a content object,
and for adding a service.


=== Zope3/src/zope/app/browser/container/adding.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/container/adding.py:1.5	Mon Feb  3 11:34:40 2003
+++ Zope3/src/zope/app/browser/container/adding.py	Tue Mar  4 11:28:48 2003
@@ -68,7 +68,7 @@
             view_name = name[2:]
         else:
             view_name = name
-            
+
         view = queryView(self, view_name, request)
         if view is not None:
             return view
@@ -87,17 +87,24 @@
     index = ViewPageTemplateFile("add.pt")
 
     def addingInfo(wrapped_self):
-        """Return menu data"""
+        """Return menu data.
+
+        This is sorted with title as primary key, and description
+        as secondary key.
+        """
         menu_service = getService(wrapped_self.context, "BrowserMenu")
-        return menu_service.getMenu(wrapped_self.menu_id,
-                                    wrapped_self,
-                                    wrapped_self.request)
+        result = menu_service.getMenu(wrapped_self.menu_id,
+                                      wrapped_self,
+                                      wrapped_self.request)
+        result.sort(lambda a, b: cmp((a['title'], a['description']),
+                                     (b['title'], b['description'])))
+        return result
     addingInfo = ContextMethod(addingInfo)
 
     def action(self, type_name, id=''):
         if type_name.startswith('@@'):
             type_name = type_name[2:]
-        
+
         if queryView(self, type_name, self.request) is not None:
             url = "%s=%s" % (type_name, id)
             self.request.response.redirect(url)