diff MoinMoin/themes/__init__.py @ 1123:ebc4f8213e74

Add a flat subitem index for show item view.
author Sam Toyer <samATqxcvDOTnet>
date Fri, 02 Dec 2011 16:46:24 +1000
parents 5479a3b62b9f
children 211e5d99c842
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Thu Dec 01 21:20:45 2011 +1000
+++ b/MoinMoin/themes/__init__.py	Fri Dec 02 16:46:24 2011 +1000
@@ -10,6 +10,8 @@
 
 import urllib
 
+from operator import itemgetter
+
 from flask import current_app as app
 from flask import g as flaskg
 from flask import url_for, request
@@ -113,6 +115,20 @@
             breadcrumbs.append((wiki_name, item_name, href, exists, err))
         return breadcrumbs
 
+    def subitem_index(self, item_name):
+        """
+        Get a list of subitems for the given item_name
+
+        :rtype: list
+        :returns: list of item tuples (item_name, item_title, item_mime_type, has_children)
+        """
+        from MoinMoin.items import Item
+        item = Item.create(item_name)
+        item_index = item.get_detailed_index(item.flat_index())
+        # Sort items by whether or not they have children, then by name:
+        item_index.sort(key=itemgetter(-1, 0))
+        return item_index
+
     def userhome(self):
         """
         Assemble arguments used to build user homepage link