Exemplo n.º 1
0
 def spawn(self, spec, **kw):
     """
     Create a new ActionRequest using default values from this one 
     and the action specified by `spec`.
     
     """
     if isinstance(spec, ActionRequest):
         for k, v in kw.items():
             assert hasattr(spec, k)
             setattr(spec, k, v)
         #~ if kw:
             #~ ar = ar.spawn(**kw)
             #~ raise Exception(20130327)
         spec.setup_from(self)
     else:
         from lino.core.menus import create_item
         mi = create_item(spec)
         #~ print 20130425, __file__, mi.bound_action
         kw.setdefault('user', self.user)
         kw.setdefault('subst_user', self.subst_user)
         kw.setdefault('renderer', self.renderer)
         kw.setdefault('requesting_panel', self.requesting_panel)
         spec = mi.bound_action.request(**kw)
     #~ ar.user = self.user
     #~ ar.subst_user = self.subst_user
     #~ ar.renderer = self.renderer
     return spec
Exemplo n.º 2
0
    def spawn(self, spec, **kw):
        "See :meth:`rt.ActionRequest.spawn`."

        if isinstance(spec, ActionRequest):
            for k, v in kw.items():
                assert hasattr(spec, k)
                setattr(spec, k, v)
            spec.setup_from(self)
        elif isinstance(spec, BoundAction):
            spec = spec.request(**kw)
            spec.setup_from(self)
        else:
            from lino.core.menus import create_item
            mi = create_item(spec)
            kw.setdefault('user', self.user)
            kw.setdefault('subst_user', self.subst_user)
            kw.setdefault('renderer', self.renderer)
            kw.setdefault('requesting_panel', self.requesting_panel)
            spec = mi.bound_action.request(**kw)
        return spec