l.s.w._.enabled_with_permission : class documentation

Part of lp.services.webapp View In Hierarchy

Function decorator that disables the output link unless the current
user has the given permission on the context.

This class is instantiated by programmers who want to apply this
decorator.

Use it like:

    @enabled_with_permission('launchpad.Admin')
    def somemenuitem(self):
        return Link('+target', 'link text')
Method __init__ Make a new enabled_with_permission function decorator.
Method __call__ Called by the decorator machinery to return a decorated function.
def __init__(self, permission):
Make a new enabled_with_permission function decorator.

permission is the string permission name, like 'launchpad.Admin'.

def __call__(self, func):
Called by the decorator machinery to return a decorated function.

Returns a new function that calls the original function, gets the link that it returns, and depending on the permissions granted to the logged-in user, disables the link, before returning it to the called.

API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.