def __call__(self, f, prewrapper_func=None):
        """
        This method is called on execution of the decorator to get the wrapper
        defined inside. The C{prewrapper_func} keyword argument is available for
        subclasses. If defined, the output of the prewrapper function is
        returned instead of the wrapper function. The prewrapper function 
        should have one argument: C{wrapper} which is the original function
        that would have been returned.
        """
        def require_obj_permissions_wrapper(obj, *args, **kw):
            """
            Wrapper for the called method that checks the permissions before
            calling the method.
            """
            # check for the permission
            try:
                if self.pop_user_kw:
                    user = kw.pop(self.user_kw)
                else:
                    user = kw[self.user_kw]
            except __HOLE__:
                raise PermissionSignatureError(self.user_kw)

            missing, temp = ExpedientPermission.objects.get_missing_for_target(
                user, self.perm_names, obj)

            if missing:
                raise PermissionDenied(missing.name, obj, user)
            
            # All is good. Call the function
            return f(obj, *args, **kw)
        
        # call the prewrapper if it is defined
        if prewrapper_func:
            return prewrapper_func(require_obj_permissions_wrapper)
        else:
            return require_obj_permissions_wrapper
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/common/permissions/decorators.py/require_obj_permissions.__call__