def allow(methods=None, debug=False):
 if (not isinstance(methods, (tuple, list))):
  methods = [methods]
 methods = [m.upper() for m in methods if m]
 if (not methods):
  methods = ['GET', 'HEAD']
 elif (('GET' in methods) and ('HEAD' not in methods)):
  methods.append('HEAD')
 cherrypy.response.headers['Allow'] = ', '.join(methods)
 if (cherrypy.request.method not in methods):
  if debug:
   cherrypy.log(('request.method %r not in methods %r' % (cherrypy.request.method, methods)), 'TOOLS.ALLOW')
  raise cherrypy.HTTPError(405)
 elif debug:
  cherrypy.log(('request.method %r in methods %r' % (cherrypy.request.method, methods)), 'TOOLS.ALLOW')

def allow ( methods = None , debug = False ) : if ( not isinstance ( methods , ( tuple , list ) ) ) : methods = [ methods ] methods = [ m . upper ( ) for m in methods if m ] if ( not methods ) : methods = [ 'GET' , 'HEAD' ] elif ( ( 'GET' in methods ) and ( 'HEAD' not in methods ) ) : methods . append ( 'HEAD' ) cherrypy . response . headers [ 'Allow' ] = ', ' . join ( methods ) if ( cherrypy . request . method not in methods ) : if debug : cherrypy . log ( ( 'request.method %r not in methods %r' % ( cherrypy . request . method , methods ) ) , 'TOOLS.ALLOW' ) raise cherrypy . HTTPError ( 405 ) elif debug : cherrypy . log ( ( 'request.method %r in methods %r' % ( cherrypy . request . method , methods ) ) , 'TOOLS.ALLOW' )
raise 405 if request .