def menupath_role(typ, rawtext, text, *args, **kwargs): a = resolve_action(text) mi = find_menu_item(a) if mi is None: raise Exception("Unknown menu descriptor %s" % text) text = menuselection_text(mi) rawtext = menuselection(mi) return menusel_role('menuselection', rawtext, text, *args, **kwargs)
def doit(): # profile = ar.get_user().profile # menu = settings.SITE.get_site_menu(settings.SITE.kernel, profile) # mi = menu.find_item(spec) mi = find_menu_item(spec) if mi is None: raise Exception("Invalid spec {0}".format(spec)) print(menuselection_text(mi))
def actors_overview_ul(model_reports): items = [] for tb in model_reports: desc = actor_ref(tb) #~ label = unicode(tb.title or tb.label) #~ desc += " (%s)" % str(tb) desc += " (%s)" % typeref(tb) mi = find_menu_item(tb.default_action) if mi is not None: desc += _(" (Menu %s)") % menuselection(mi) #~ print(unicode(mi.label).strip()) if tb.help_text: desc += " -- " + unicode(tb.help_text).strip() items.append(desc) return rstgen.ul(items)
def get_rst(self): with translation.override(self.language): #~ set_language(lng) actor_names = ' '.join(self.content).split() items = [] for an in actor_names: cls = settings.SITE.modules.resolve(an) if not isinstance(cls, type): raise Exception("%s is not an actor." % self.content[0]) desc = "**{0}** (:class:`{1} <{2}>`)".format( force_text(cls.label), cls.__name__, cls.__module__ + '.' + cls.__name__) mi = find_menu_item(cls.default_action) if mi is not None: desc += _(" (Menu %s)") % menuselection(mi) #~ print(unicode(mi.label).strip()) if cls.help_text: desc += " : " + force_text(cls.help_text).strip() # items.append("%s : %s" % (actor_ref(cls), cls.help_text or '')) items.append(desc) return rstgen.ul(items)
def get_rst(self): with translation.override(self.language): #~ set_language(lng) actor_names = ' '.join(self.content).split() items = [] for an in actor_names: cls = settings.SITE.modules.resolve(an) if not isinstance(cls, type): raise Exception("%s is not an actor." % self.content[0]) desc = "**{0}** (:class:`{1} <{2}>`)".format( force_unicode(cls.label), cls.__name__, cls.__module__ + '.' + cls.__name__ ) mi = find_menu_item(cls.default_action) if mi is not None: desc += _(" (Menu %s)") % menuselection(mi) #~ print(unicode(mi.label).strip()) if cls.help_text: desc += " : " + force_unicode(cls.help_text).strip() # items.append("%s : %s" % (actor_ref(cls), cls.help_text or '')) items.append(desc) return rstgen.ul(items)