예제 #1
0
    def get_breadcrumb(cls, handler, params):
        title = cls.title % params
        entry = MenuEntry(title, cls.__name__, params)
        entry.children = cls.get_childmenu(handler, params)
        items = [entry]

        if len(params) > 0:
            parent_params = params.copy()
            parent_params.popitem()
        else:
            parent_params = []

        if cls.parent is not None and hasattr(handler, 'parent') and \
            hasattr(cls.parent, 'get_breadcrumb'):
            items.extend(cls.parent.get_breadcrumb(handler, parent_params))
        return items
예제 #2
0
 def menu(self):
     params = OrderedDict(zip(self.params, self.path_args))
     new_top_level = list(GlobalMenu)
     menu = self.get_menu(self, params)
     for i, child in enumerate(GlobalMenu):
         if child.url_name == menu.url_name:
             new_top_level[i] = menu
             break
     else:
         new_top_level.append(menu)
     return MenuEntry(None, None, None, new_top_level, active=True)
예제 #3
0
 def get_selfmenu(cls, handler, params):
     my_params = OrderedDict((key, params.get(key)) for key in cls.params)
     return MenuEntry(cls.title % params, cls.__name__, my_params)