Make your decoratorsΒΆ

This module enables piling rules on each others.

Consider this simple rule:

def is_authenticated(user, *args, **kwargs):
    return user and user.is_authenticated()

It can of course be used directly:

rules_light.registry['do_something'] = is_authenticated

But if defined using make_decorator as such:

@rules_light.make_decorator
def is_authenticated(user, *args, **kwargs):
    return user and user.is_authenticated()

Then you can use it to decorate other rules too:

@is_authenticated
def my_book(user, rule, book):
    return user == book.author

rules_light.registry['do_something'] = my_book