l.s.w.a.available_with_permission : class documentation

Part of lp.services.webapp.authorization View In Hierarchy

Function decorator that ensures the user has the given permission on
a context object.

The context object is one of the function arguments and is specified by
nominating the argument name. If no keyword arguments are present, then the
first non-keyword argument is used.

Use it like:

    @available_with_permission('launchpad.Edit', 'context_arg')
    def some_function(self, context_arg, another_arg):
        # do something

And the calling code would be:
    obj.some_function(context, another)
or
    obj.some_function(context_arg=context, another_arg=another)
Method __init__ Make a new available_with_permission function decorator.
Method __call__ Undocumented
def __init__(self, permission, context_parameter):
Make a new available_with_permission function decorator.

`permission` is the string permission name, like 'launchpad.Edit'.
`context_parameter` is the name of the function argument which
                    contains the context object.
def __call__(self, func):
Undocumented
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.