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
bridgekeeper.rules should expose a R class, with an API similar to django.db.models.Q.
This class would take keyword arguments, with either constants, functions that take a user, or other Bridgekeeper rules as values.
This class should take keyword arguments, where keys are attribute names (traversing relationships with __ where applicable), and values are either database values, functions that take a user, or (where the target attribute is a relationship) another Bridgekeeper rule object.
As an example of what this might look like, here's a couple of snippets from the documentation, alongside the equivalent rule expressed in terms of R.
perms['shrubbery.update_shrubbery'] =Relation(
'branch',
models.Branch,
# This rule gets checked against the branch object, not the shrubberyAttribute('store', lambdauser: user.profile.branch.store),
)
perms['shrubbery.update_shrubbery'] =R(branch__store=lambdauser: user.profile.branch.store)
As an aside, lookups (__gt, __in etc) could also be supported. This could be done with each one being a rule object of its own that takes a property and a value_or_function, since they'd need to do one thing for Q lookups and another for Python-land checks, and rule objects are already a mechanism for doing that. My intention is not to do that at first though, since we haven't encountered a need for testing anything other than equality yet.
bridgekeeper.rules
should expose aR
class, with an API similar todjango.db.models.Q
.This class would take keyword arguments, with either constants, functions that take a user, or other Bridgekeeper rules as values.
This class should take keyword arguments, where keys are attribute names (traversing relationships with
__
where applicable), and values are either database values, functions that take a user, or (where the target attribute is a relationship) another Bridgekeeper rule object.As an example of what this might look like, here's a couple of snippets from the documentation, alongside the equivalent rule expressed in terms of
R
.The text was updated successfully, but these errors were encountered: