def extra_oauth2_scope(*scopes):
 def extra_oauth2_wrapper(fn):
  @functools.wraps(fn)
  def wrapper_fn(*a, **kw):
   if (not c.oauth_user):
    return fn(*a, **kw)
   elif c.oauth_scope.has_access(c.site.name, set(scopes)):
    return fn(*a, **kw)
   else:
    raise OAuth2Scope.InsufficientScopeError(scopes)
  return wrapper_fn
 return extra_oauth2_wrapper

def extra_oauth2_scope ( * scopes ) : def extra_oauth2_wrapper ( fn ) : @ functools . wraps ( fn ) def wrapper_fn ( * a , ** kw ) : if ( not c . oauth_user ) : return fn ( * a , ** kw ) elif c . oauth_scope . has_access ( c . site . name , set ( scopes ) ) : return fn ( * a , ** kw ) else : raise OAuth2Scope . InsufficientScopeError ( scopes ) return wrapper_fn return extra_oauth2_wrapper
wrap a function so that it only returns data if user has all scopes when not in an oauth2 context .