def prepare_private_key():
 if (request.method != 'GET'):
  return
 if request.args.get('view_only', ''):
  return
 if request.referrer:
  referrer_parsed = urlparse.urlparse(request.referrer)
  scheme = referrer_parsed.scheme
  key = urlparse.parse_qs(urlparse.urlparse(request.referrer).query).get('view_only')
  if key:
   key = key[0]
 else:
  scheme = None
  key = None
 if (key and (not session.is_authenticated)):
  new_url = add_key_to_url(request.url, scheme, key)
  return redirect(new_url, code=http.TEMPORARY_REDIRECT)

def prepare_private_key ( ) : if ( request . method != 'GET' ) : return if request . args . get ( 'view_only' , '' ) : return if request . referrer : referrer_parsed = urlparse . urlparse ( request . referrer ) scheme = referrer_parsed . scheme key = urlparse . parse_qs ( urlparse . urlparse ( request . referrer ) . query ) . get ( 'view_only' ) if key : key = key [ 0 ] else : scheme = None key = None if ( key and ( not session . is_authenticated ) ) : new_url = add_key_to_url ( request . url , scheme , key ) return redirect ( new_url , code = http . TEMPORARY_REDIRECT )
before_request handler that checks the referer header to see if the user is requesting from a view-only link .