def methods_via_query_allowed(handler_method):
 def redirect_if_needed(self, *args, **kwargs):
  real_verb = self.request.get('_method', None)
  if ((not real_verb) and ('X-HTTP-Method-Override' in self.request.environ)):
   real_verb = self.request.environ['X-HTTP-Method-Override']
  if real_verb:
   logging.debug('Redirected from POST. Detected method override = %s', real_verb)
   method = real_verb.upper()
   if (method == 'HEAD'):
    self.head(*args, **kwargs)
   elif (method == 'PUT'):
    self.put(*args, **kwargs)
   elif (method == 'DELETE'):
    self.delete(*args, **kwargs)
   elif (method == 'TRACE'):
    self.trace(*args, **kwargs)
   elif (method == 'OPTIONS'):
    self.head(*args, **kwargs)
   elif (method == 'POST'):
    self.post(*args, **kwargs)
   elif (method == 'GET'):
    self.get(*args, **kwargs)
   else:
    self.error(405)
  else:
   handler_method(self, *args, **kwargs)
 return redirect_if_needed

def methods_via_query_allowed ( handler_method ) : def redirect_if_needed ( self , * args , ** kwargs ) : real_verb = self . request . get ( '_method' , None ) if ( ( not real_verb ) and ( 'X-HTTP-Method-Override' in self . request . environ ) ) : real_verb = self . request . environ [ 'X-HTTP-Method-Override' ] if real_verb : logging . debug ( 'Redirected from POST. Detected method override = %s' , real_verb ) method = real_verb . upper ( ) if ( method == 'HEAD' ) : self . head ( * args , ** kwargs ) elif ( method == 'PUT' ) : self . put ( * args , ** kwargs ) elif ( method == 'DELETE' ) : self . delete ( * args , ** kwargs ) elif ( method == 'TRACE' ) : self . trace ( * args , ** kwargs ) elif ( method == 'OPTIONS' ) : self . head ( * args , ** kwargs ) elif ( method == 'POST' ) : self . post ( * args , ** kwargs ) elif ( method == 'GET' ) : self . get ( * args , ** kwargs ) else : self . error ( 405 ) else : handler_method ( self , * args , ** kwargs ) return redirect_if_needed
a decorator to automatically re-route overloaded posts that specify the real http method in a _method query string .