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

Make permissions in dynamic item lazy evaluated #303

Merged
merged 1 commit into from
Aug 5, 2021

Conversation

jgadelange
Copy link
Contributor

This fixes #302. By adding lazy evaluation for the permissions we prevent
manage.py breaking down when using dynamic items with permissions in an
AppConfig.ready().

cleaned_permissions.append(perm)

item_obj.permissions = cleaned_permissions or []
item_obj.permissions = SimpleLazyObject(lambda: clean_permissions(access_by_perms))
Copy link

@wkleinheerenbrink wkleinheerenbrink Jul 26, 2021

Choose a reason for hiding this comment

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

Perhaps is better to return a SimpleLazyObject from within clean_permissions. The string parsing/checking etc. isn't a heavy calculation so can happen right away (with the advantage of having feedback directly when starting the server).

The only contents of the SimpleLazyObject would be these lines: https://github.com/idlesign/django-sitetree/pull/303/files#diff-ccaf61b8a24236aa8dced71a05c2fe1f8b811e09ee8e1b14ca2c71eabc6d82ecR64-R67

@jgadelange
Copy link
Contributor Author

I also created two alternatives solutions (see fluxility@af46e52 and fluxility@3386ef7).

Please let me know if you prefer one of the other solutions better.

@idlesign
Copy link
Owner

Thank you.
I'll try to check this out in a week.

sitetree/tests/test_utils.py Outdated Show resolved Hide resolved
@idlesign
Copy link
Owner

idlesign commented Aug 1, 2021

I'd like to ask you to rebase on current master where the proper CI Action is in place.

@coveralls
Copy link

coveralls commented Aug 3, 2021

Coverage Status

Coverage increased (+0.01%) to 95.827% when pulling 725a42d on fluxility:master into a2d77e9 on idlesign:master.

This fixes idlesign#302. By adding lazy evaluation for the permissions we prevent
manage.py breaking down when using dynamic items with permissions in an
AppConfig.ready().
@idlesign idlesign merged commit 8685369 into idlesign:master Aug 5, 2021
@idlesign
Copy link
Owner

idlesign commented Aug 5, 2021

Thank you. Merged.

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

Successfully merging this pull request may close these issues.

compose_dynamic_tree with access_by_perms called in config.ready results in database errors
4 participants