Once again - how to call an action from within another?

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
easy
Posts: 46
Joined: Wed Dec 05, 2007 10:05 pm

Once again - how to call an action from within another?

Post by easy » Tue Sep 01, 2009 10:17 am

Hi all,

After I updated to a new release (1194), my plugin stopped working. I'we managed to get to the point, that I can't call another action anymore in the way BitMonster has told me lot of time ago.
Isn't working anymore:

Code: Select all

class MenuExecute(eg.ActionClass):
    name = "Execute"
    description = "Triggers an event associated with current menu item."
    iconFile = 'icons/enter'
    def __call__(self):
		self.plugin.info.actions["Close"]()
Is still working (but shouldn't be used i think):

Code: Select all

class MenuExecute(eg.ActionClass):
    name = "Execute"
    description = "Triggers an event associated with current menu item."
    iconFile = 'icons/enter'
    def __call__(self):
		eg.plugins.OSMenu.Close()

So, what could be the correct calling of action?

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Once again - how to call an action from within another?

Post by Bitmonster » Tue Sep 01, 2009 1:44 pm

Ok, currently it would be:

Code: Select all

self.plugin.info.actions["ActionClsName"]()(*actionArgs)
But you should avoid it at all. The implementation details for actions might change again in the future. So better put your commonly accessed code into the plugin and let the actions call it.

Code: Select all

class MyPlugin(eg.PluginBase):
    def MyClose(self):
       ...whatever....

class Close(eg.ActionBase):
    def __call__(self):
        self.plugin.MyClose()

class MenuExecute(eg.ActionBase):
    def __call__(self):
        self.plugin.MyClose()
        ...whatever...
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

Post Reply