You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
(copied from internal github, original issue opened by alejandro)
baya.utils.has_permission fails with the following error messages when view function (param fn) is wrapped like so: requires(DynamicRolesNode(DjangoRequestGroupFormatter('%s', 'name'))
Traceback (most recent call last):
File "/Users/alejandro/Projects/baya/baya/tests/test_group_formatter.py", line 16, in test_has_permission_url_param
perm = has_permission(view_func, AnonymousUser(), 'any')
File "/Users/alejandro/Projects/baya/baya/utils.py", line 60, in has_permission
if check_perm(user):
File "/Users/alejandro/Projects/baya/baya/permissions.py", line 106, in user_has_any_permission
return (self.user_has_get_permission(user) or
File "/Users/alejandro/Projects/baya/baya/permissions.py", line 93, in user_has_get_permission
return self._has_permission(user, self.get_requires)
File "/Users/alejandro/Projects/baya/baya/permissions.py", line 87, in _has_permission
return user_in_group(user, membership_node, request=request)
File "/Users/alejandro/Projects/baya/baya/utils.py", line 26, in user_in_group
return PermissionChecker(user_groups).visit(group, **kwargs)
File "/Users/alejandro/Projects/baya/baya/visitors.py", line 27, in visit
return self._visit_roles_node(node, **kwargs)
File "/Users/alejandro/Projects/baya/baya/visitors.py", line 182, in _visit_roles_node
return roles_node.get_roles_set(**kwargs) <= self._roles_set
File "/Users/alejandro/Projects/baya/baya/membership.py", line 142, in get_roles_set
result = _callable(**kwargs)
File "/Users/alejandro/Projects/baya/baya/dynamic_roles.py", line 63, in __call__
url_kwargs = request.resolver_match.kwargs
AttributeError: 'NoneType' object has no attribute 'resolver_match'
To recreate this, checkout branch has_permission_breaks_drgf and run make test.
I discovered this when I was more thoroughly testing the new templatetag can_user_perform_action.
Why is this happening?
DynamicRolesNode stores callables that return sets of groups that are called runtime when permission checking occurs. When that callable is a DjangoRequestGroupFormatter, problems occur because there is no request object to grab kwargs from for formatting the groups to return.
How to fix?
Probably make the DjangoRequestGroupFormatter not dependent on the request object to do the url parsing for it. There's got to be another way to pull out the kwargs and params of a url without doing it through a request.
I'll be trying to figure out how to solve this the has_permission_breaks_drgf branch if the above solution sounds right.
Scratch that. I'm not sure how to fix this...
The text was updated successfully, but these errors were encountered:
(copied from internal github, original issue opened by alejandro)
baya.utils.has_permission
fails with the following error messages when view function (paramfn
) is wrapped like so:requires(DynamicRolesNode(DjangoRequestGroupFormatter('%s', 'name'))
To recreate this,
checkout branch has_permission_breaks_drgf
and runmake test
.I discovered this when I was more thoroughly testing the new templatetag
can_user_perform_action
.Why is this happening?
DynamicRolesNode stores callables that return sets of groups that are called runtime when permission checking occurs. When that callable is a DjangoRequestGroupFormatter, problems occur because there is no request object to grab kwargs from for formatting the groups to return.
How to fix?
Probably make the DjangoRequestGroupFormatter not dependent on the request object to do the url parsing for it. There's got to be another way to pull out the kwargs and params of a url without doing it through a request.I'll be trying to figure out how to solve this thehas_permission_breaks_drgf
branch if the above solution sounds right.Scratch that. I'm not sure how to fix this...
The text was updated successfully, but these errors were encountered: