def policy_decorator(scope):
 def outer(func):
  @functools.wraps(func)
  def wrapped(self, context, target, *args, **kwargs):
   check_policy(context, func.__name__, target, scope)
   return func(self, context, target, *args, **kwargs)
  return wrapped
 return outer

def policy_decorator ( scope ) : def outer ( func ) : @ functools . wraps ( func ) def wrapped ( self , context , target , * args , ** kwargs ) : check_policy ( context , func . __name__ , target , scope ) return func ( self , context , target , * args , ** kwargs ) return wrapped return outer
check corresponding policy prior of wrapped method to execution .