Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_services undocumented #37

Open
nerdoc opened this issue Jun 18, 2018 · 0 comments
Open

load_services undocumented #37

nerdoc opened this issue Jun 18, 2018 · 0 comments

Comments

@nerdoc
Copy link
Contributor

nerdoc commented Jun 18, 2018

I really had a hard time finding out how PluginGlobals.load_services() works - I didn't make it. Is there any kind of documentation besides the few lines in the [pdf](https://software.sandia.gov/trac/pyutilib/export/1831/pyutilib.component.doc/trunk/doc/plugin/pca.pdf]?

AFAIK, and after having worked myself through the code of the loader, you have to import a Loader class first which implements IPluginLoader before calling load_services().
So:

# plugin.py
class Test:
    implements(ITest)
    def test():
        print("test)
# main.py
class ITest(Interface)
    def test():
        pass

class Main:
    test_extension = ExtensionPoint(ITest)
    
    def __init__(self):    
        loader = ImportLoader()
        PluginGlobals.get_env().load_services(path="./plugins", auto_disable=False)

    # test it:
    for ep in self.test_extension:
        ep.test()
  • Does this work (here test() is never called, the for loop does not iterate at all over the plugins)?
  • Is the get_env() necessary (the pdf doc doesn't mention it)?
  • even if I write auto_disable=False the plugin is not called in the following context.
    Is there any chance that the documentation gets updated?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant