Skip to content

Commit 3f1ce6b

Browse files
committed
Enable entity category import from module search path
This enhancement causes an entity category import to first be tried from the general module search path, and if that fails then to fall back to the current default of importing saml2.entity_category.<module>. This allows deployers to overlay their own customized versions of entity category modules like edugain.py that contain CoCo. This is helpful since the list of attributes to be included as part of the entity category may not be globally the same for all deployments. Such is the case with CoCo where the list of attributes changes from federation to federation and deployment to deployment.
1 parent d3aa78e commit 3f1ce6b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/saml2/assertion.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,11 @@ def compile(self, restrictions):
353353
else:
354354
ecs = []
355355
for cat in items:
356-
_mod = importlib.import_module(
357-
"saml2.entity_category.%s" % cat)
356+
try:
357+
_mod = importlib.import_module(cat)
358+
except ImportError:
359+
_mod = importlib.import_module(
360+
"saml2.entity_category.%s" % cat)
358361
_ec = {}
359362
for key, items in _mod.RELEASE.items():
360363
alist = [k.lower() for k in items]

0 commit comments

Comments
 (0)