Skip to content

Commit

Permalink
Fix an error when loading namespace packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ale-rt committed Feb 26, 2025
1 parent f5de104 commit 10ec659
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 10ec659

Please sign in to comment.