def _protect_original_resources(f):
 @functools.wraps(f)
 def wrapped(*args, **kwargs):
  ctx = request.context
  if ('resources' in ctx):
   orig = ctx.get('protected_resources')
   if (not orig):
    ctx['protected_resources'] = ctx['resources']
   memo = {id(constants.ATTR_NOT_SPECIFIED): constants.ATTR_NOT_SPECIFIED}
   ctx['resources'] = copy.deepcopy(ctx['protected_resources'], memo=memo)
  return f(*args, **kwargs)
 return wrapped

def _protect_original_resources ( f ) : @ functools . wraps ( f ) def wrapped ( * args , ** kwargs ) : ctx = request . context if ( 'resources' in ctx ) : orig = ctx . get ( 'protected_resources' ) if ( not orig ) : ctx [ 'protected_resources' ] = ctx [ 'resources' ] memo = { id ( constants . ATTR_NOT_SPECIFIED ) : constants . ATTR_NOT_SPECIFIED } ctx [ 'resources' ] = copy . deepcopy ( ctx [ 'protected_resources' ] , memo = memo ) return f ( * args , ** kwargs ) return wrapped
wrapper to ensure that mutated resources are discarded on retries .