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

enable defaults for custom attribute release using '' or 'default' key #99

Merged
merged 1 commit into from
May 30, 2017

Conversation

leifj
Copy link
Contributor

@leifj leifj commented May 30, 2017

This also contains a small utility function that I will use to refactor some of my other pull requests later. There are tests covering this already so it should be safe as long as the tests work.

@leifj leifj requested a review from johanlundberg May 30, 2017 10:10
def get_dict_defaults(d, *keys):
for key in keys:
d = d.get(key, d.get("", d.get("default", {})))
return d
Copy link
Contributor

@johanlundberg johanlundberg May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I understanding correctly that you want to accomplish this in other words?

def get_dict_defaults(d, *keys):
    for key in keys:
        if key in d:
            return d[key]
        elif '' in d or 'default' in d:
            return d.get('', d.get('default'))
    return dict()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I want to traverse the entire length of the "key chain" finding the most specific branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically this is the _config function I'm using in my two other PRs for attribute authz and attribute generation. Its a pattern for config that I think @skoranda uses too in places - esp when you need to override behaviour specified by metadata on a per-Idp, per-sp+idp or globally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I get it, you want to reuse d and the keys are in hierarchical order.

@johanlundberg johanlundberg merged commit 0e5afd4 into IdentityPython:master May 30, 2017
@leifj leifj deleted the attribute-filter-config branch May 31, 2017 08:18
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