def referer(pattern, accept=True, accept_missing=False, error=403, message='Forbidden Referer header.', debug=False):
 try:
  ref = cherrypy.serving.request.headers['Referer']
  match = bool(re.match(pattern, ref))
  if debug:
   cherrypy.log(('Referer %r matches %r' % (ref, pattern)), 'TOOLS.REFERER')
  if (accept == match):
   return
 except KeyError:
  if debug:
   cherrypy.log('No Referer header', 'TOOLS.REFERER')
  if accept_missing:
   return
 raise cherrypy.HTTPError(error, message)

def referer ( pattern , accept = True , accept_missing = False , error = 403 , message = 'Forbidden Referer header.' , debug = False ) : try : ref = cherrypy . serving . request . headers [ 'Referer' ] match = bool ( re . match ( pattern , ref ) ) if debug : cherrypy . log ( ( 'Referer %r matches %r' % ( ref , pattern ) ) , 'TOOLS.REFERER' ) if ( accept == match ) : return except KeyError : if debug : cherrypy . log ( 'No Referer header' , 'TOOLS.REFERER' ) if accept_missing : return raise cherrypy . HTTPError ( error , message )
raise httperror if referer header does/does not match the given pattern .