Skip to content

New plugin activation option: make callable and parameter to activate during initialisation #19

@danwos

Description

@danwos

We could make a plugin-instance directly callable, which should have the same result as calling the activate() routine. So this is somehow a shortcut.

class MyPlugin(GwBasePattern):
    ...
    def activate():
        pass

plugin = MyPlugin()
plugin.activate()
# or
plugin()

We could do this by using __call__ inside GwBasePattern:

class GwBasePattern:
    def __cal__(self, *args, **kwargs):
        self.activate(*args, **kwargs)

Another idea to automatically activate plugins during initialisation:

plugin = MyPlugin(activate=True)

The GwBasePattern would check this during __init__:

class GwBasePattern:
    def __init__(self, *args, **kwargs):
        if "activate" in kwargs.keys() and kwargs["activate"] is True:
           self.activate()

Maybe there could also be an config-option, to activate plugins during initialisation automatically.
But I'm not sure, for which plugins __init__ gets called currently (only by user, all registered plugin, ... ).
Must check is in the pluginmananger.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions