Skip to content

Servlet import fix #2

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

One of my legacy apps does some introspection and relies on servlets showing up in sys.modules. This code failed. In investigating, I discovered a subtle issues with the servlet import code. This PR fixes the issue and includes new tests.

Initially I found that servlets modules were not being put into sys.modules due to a simple typo. After fixing that, I found that sys.modules was being updated with the key 'MyContext.MyServlet' (correct), but the module name as visible from within the servlet (e.g. name) was simply 'MyServlet', not the fully qualified module name 'MyContext.Servlet', so there was an inconsistency.

I also added a test to make sure ImportManager monitors the import servlet file for changes. It was working fine beforehand, but I wanted to test and make sure I didn't break anything with my changes.

@Cito
Copy link
Member

Cito commented Jan 7, 2020

Thanks a lot, will look into that later.

Note that monitoring servlet files is not absolutely necessary - if you disable servlet caching in Application.config, which is the default in development mode, they are always loaded new, which has the same effect. However, if you want to simulate production with caching, and also monitor library files for changes, you need monitoring. In Webware for Python 2 this was the task of the "ImportSpy", which has been replaced by "hupper" in Webware for Python 3.

@Cito Cito merged commit 382970e into WebwareForPython:master Jan 9, 2020
@Cito
Copy link
Member

Cito commented Jan 9, 2020

This will be shipped with 3.0.0a1. Thanks again, particularly for adding the test.

@jasonhildebrand jasonhildebrand deleted the servlet-import-fix 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