Skip to content

Ability to load plugins in non-web situations #1

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

Merged

Conversation

jasonhildebrand
Copy link
Contributor

Hi Christoph,

This issue came up for me trying to run the MiddleKit test suite - I needed a way to be able to import MiscUtils, etc. (which many MiddleKit classes require), but importing MiscUtils directly led to errors like this:

File "Test.py", line 9, in <module>
  from TestCommon import *
File "/src/w4py3-middlekit/webware/MiddleKit/Tests/TestCommon.py", line 12, in <module>
  from MiddleKit.Core.Klasses import Klasses
File "/src/w4py3-middlekit/webware/MiddleKit/Core/Klasses.py", line 2, in <module>
  from .Model import Model, ModelError
File "/src/w4py3-middlekit/webware/MiddleKit/Core/Model.py", line 6, in <module>
  from webware.MiscUtils.Configurable import Configurable
File "/usr/local/lib/python3.7/dist-packages/webware/MiscUtils/Configurable.py", line 9, in <module>
  from MiscUtils import AbstractError, NoDefault
ModuleNotFoundError: No module named 'MiscUtils'

I tried updating several of the imports in MiscUtils to be relative imports, but then they did not work correctly when running the Webware appserver.

The solution I arrived at was refactor the plugin loading code so that plugins can be loaded without having to instantiate an Application.

This now allows bootstrapping webware with plugins by doing:

    import webware
    webware.add_to_python_path()
    webware.load_plugins('/your/app/directory')

This will also be useful for implementing cron jobs and scripts which update database records - my legacy apps have several examples of this.

@Cito
Copy link
Member

Cito commented Jan 3, 2020

Thank you, will look into this as soon as I find time. Will release 3.0 beta and final when the plugin mechanism is stable and works with MiddleKit. Any such feedback is helpful.

@Cito Cito merged commit 1ad89a6 into WebwareForPython:master Jan 5, 2020
@Cito
Copy link
Member

Cito commented Jan 5, 2020

After merging, I reworked it a bit in 9f05837 and added tests. Let me know if it works for you with my changes. I'd like to create a new release as well - do you think we're ready for a beta release or should this be an alpha release still? While in alpha, we can still make breaking changes. Also, I'd like to add the link to the new MiddleKit project page. Shall I use the current one or will this still change?

@jasonhildebrand
Copy link
Contributor Author

I checked 9f05837 visually and looks OK to me. I will test it out shortly and let you know if there are any issues. Thanks for your work on this!

Have you ported any existing apps to w4py3? That would help determine whether to call it alpha or beta. I am taking initial steps at porting one of our legacy apps to python 3. I'll let you know how it goes.

@Cito
Copy link
Member

Cito commented Jan 6, 2020

I've just started porting a large app to w4py3, but it will take some time until it's fully ported and tested. Good idea to wait with betas until we have successfully ported one or two such real world apps. Will release another alpha version then later this week.

@jasonhildebrand
Copy link
Contributor Author

Nico and I have agreed that it makes sense for me to take over as ongoing maintain for MiddleKit.

I'll create a new repo and send you the link.

@Cito
Copy link
Member

Cito commented Jan 6, 2020

Ok, thanks.

@jasonhildebrand
Copy link
Contributor Author

The MiddleKit repo is here: https://github.com/PeaceWorksTechnologySolutions/w4py3-middlekit

@jasonhildebrand
Copy link
Contributor Author

I tested your changes in 9f05837 with MiddleKit - it is working well.

@jasonhildebrand jasonhildebrand deleted the plugin-loading branch October 7, 2021 21:25
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

Successfully merging this pull request may close these issues.

2 participants