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

Using attribute_map_dir files throw error 'No module named __init__' #954

Open
bumblebeexx opened this issue Mar 6, 2024 · 0 comments
Open
Labels

Comments

@bumblebeexx
Copy link

bumblebeexx commented Mar 6, 2024

In my SAML config I have put "attribute_map_dir": SAML_DIR / "attribute-maps",

This attribute-maps directory contains two files __init__.py and test.py

However, it causes this exception below.

Exception Type: ModuleNotFoundError at /saml2/login/
Exception Value: No module named '__init__'
...
...
File "djangosaml2/.venv/lib/python3.10/site-packages/saml2/config.py", line 338, in load
    self.load_complex(cnf)
  File "djangosaml2/.venv/lib/python3.10/site-packages/saml2/config.py", line 266, in load_complex
    acs = ac_factory(cnf.get("attribute_map_dir"))
  File "djangosaml2/.venv/lib/python3.10/site-packages/saml2/attribute_converter.py", line 67, in ac_factory
    mod = import_module(fil[:-3])

I removed __init__.py but then it threw error for test.py. It's happening because the function ac_factory() in saml2/attribute_converter.py has this code which is trying to import Python files -

if fil.endswith(".py"):

I also tried to print sys.path and it contains the full path to the map dir as set in the attribute_map_dir in config.

sys.path.insert(0, path)

I can't figure out how to get it working. Please advise the correct way to setup attribute maps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants