Exemple #1
0
    def spawn(self, spec=None, **kw):
        """Create a new action request using default values from this one and
        the action specified by `spec`.

        The first argument, `spec` can be:

        - a string with the name of a model, actor or action
        - a :class:`BoundAction` instance
        - another action request (deprecated use)

        """
        from lino.core.actors import resolve_action
        if isinstance(spec, ActionRequest):  # deprecated use
            for k, v in list(kw.items()):
                assert hasattr(spec, k)
                setattr(spec, k, v)
            spec.setup_from(self)
        elif isinstance(spec, BoundAction):
            kw.update(parent=self)
            spec = spec.request(**kw)
            # spec.setup_from(self)
        else:
            kw.update(parent=self)
            ba = resolve_action(spec)
            spec = ba.request(**kw)
            # from lino.core.menus import create_item
            # mi = create_item(spec)
            # spec = mi.bound_action.request(**kw)
        return spec
Exemple #2
0
    def spawn(self, spec=None, **kw):
        """
        Create a new action request using default values from this one and
        the action specified by `spec`.

        The first argument, `spec` can be:

        - a string with the name of a model, actor or action
        - a :class:`BoundAction` instance
        - another action request (deprecated use)

        Deprecated. Use spawn_request() if spec is
        """
        from lino.core.actors import resolve_action
        if isinstance(spec, ActionRequest):  # deprecated use
            # raise Exception("20160627 Deprecated")
            for k, v in list(kw.items()):
                assert hasattr(spec, k)
                setattr(spec, k, v)
            spec.setup_from(self)
        elif isinstance(spec, BoundAction):
            kw.update(parent=self)
            spec = spec.request(**kw)
        else:
            kw.update(parent=self)
            ba = resolve_action(spec)
            spec = ba.request(**kw)
            # from lino.core.menus import create_item
            # mi = create_item(spec)
            # spec = mi.bound_action.request(**kw)
        return spec
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
def menupath_role(typ, rawtext, text, *args, **kwargs):
    a = resolve_action(text)
    user_type = UserTypes.get_by_value('900')
    mi = user_type.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)
Exemple #6
0
def menupath_role(typ, rawtext, text, *args, **kwargs):
    a = resolve_action(text)
    user_type = UserTypes.get_by_value('900')
    mi = user_type.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)
Exemple #7
0
def create_item(spec, action=None, help_text=None, **kw):
    """
    """
    a = resolve_action(spec, action)
    if help_text is None:
        if a == a.actor.default_action:
            help_text = a.actor.help_text or a.action.help_text
        else:
            help_text = a.action.help_text
    if help_text is not None:
        kw.update(help_text=help_text)
    kw.update(action=a)
    return MenuItem(**kw)
Exemple #8
0
def create_item(spec, action=None, help_text=None, **kw):
    """
    """
    a = resolve_action(spec, action)
    if help_text is None:
        if a == a.actor.default_action:
            help_text = a.actor.help_text or a.action.help_text
        else:
            help_text = a.action.help_text
    if help_text is not None:
        kw.update(help_text=help_text)
    kw.update(action=a)
    return MenuItem(**kw)
Exemple #9
0
 def find_item(self, spec):
     bound_action = resolve_action(spec)
     for mi in self.walk_items():
         if mi.bound_action == bound_action:
             return mi
Exemple #10
0
 def find_item(self, spec):
     bound_action = resolve_action(spec)
     for mi in self.walk_items():
         if mi.bound_action == bound_action:
             return mi