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

Fix an error when loading namespace packages #28

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/25.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an error when loading namespace packages. [ale-rt]
9 changes: 5 additions & 4 deletions src/plone/autoinclude/loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pkg_resources import iter_entry_points
from pkg_resources import resource_filename
from pkg_resources import working_set
from zope.configuration.xmlconfig import include
Expand Down Expand Up @@ -37,14 +36,16 @@ def load_z3c_packages(target=""):
This returns a dictionary of package names and packages.
"""
dists = {}
for ep in iter_entry_points(group="z3c.autoinclude.plugin"):

for ep in importlib.metadata.entry_points(group="z3c.autoinclude.plugin"):
# If we look for target 'plone' then only consider entry points
# that are registered for this target (module name).
# But if the entry point is not registered for a specific target,
# we can include it.
if target and ep.module_name != target:
module_name = ep.dist.name
if target and module_name != target:
continue
module_name = ep.dist.project_name.replace("-", "_")

if module_name not in _known_module_names:
try:
dist = importlib.import_module(module_name)
Expand Down
Loading