Mercurial > moin > 2.0
diff MoinMoin/items/__init__.py @ 993:6dd0b0755b6a
disconnected levels now shown in index, fixes #75
todo: treat non-existent item listed in index.
author | "Luis Henrique Fagundes <lhfagundes@gmail.com>" |
---|---|
date | Fri, 28 Oct 2011 00:16:20 -0200 |
parents | 5bf6d7a2ffcf |
children | 9fd0a6a988bb afe0afe4e1a6 |
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py Wed Oct 26 23:20:57 2011 -0200 +++ b/MoinMoin/items/__init__.py Fri Oct 28 00:16:20 2011 -0200 @@ -525,13 +525,34 @@ for rev in revs] return items + def _connect_levels(self, index): + new_index = [] + last = self.name + for item in index: + name = item[0] + + while not name.startswith(last): + last = last.rpartition('/')[0] + + missing_layers = name.split('/')[last.count('/')+1:-1] + + for layer in missing_layers: + last = '/'.join([last, layer]) + new_index.append((last, last[len(self.name)+1:], u'application/x-nonexistent')) + + last = item[0] + new_index.append(item) + + return new_index + def flat_index(self, startswith=None, selected_groups=None): """ - creates an top level index of sub items of this item + creates a top level index of sub items of this item if startswith is set, filtering is done on the basis of starting letter of item name if selected_groups is set, items whose contentype belonging to the selected contenttype_groups, are filtered. """ index = self.get_index() + index = self._connect_levels(index) all_ctypes = [[ctype for ctype, clabel in contenttypes] for gname, contenttypes in CONTENTTYPE_GROUPS]