def create_http_method_map(resource):
 method_map = {}
 for method in HTTP_METHODS:
  try:
   responder = getattr(resource, ('on_' + method.lower()))
  except AttributeError:
   pass
  else:
   if callable(responder):
    method_map[method] = responder
 allowed_methods = sorted(list(method_map.keys()))
 if ('OPTIONS' not in method_map):
  opt_responder = responders.create_default_options(allowed_methods)
  method_map['OPTIONS'] = opt_responder
  allowed_methods.append('OPTIONS')
 na_responder = responders.create_method_not_allowed(allowed_methods)
 for method in HTTP_METHODS:
  if (method not in allowed_methods):
   method_map[method] = na_responder
 return method_map

def create_http_method_map ( resource ) : method_map = { } for method in HTTP_METHODS : try : responder = getattr ( resource , ( 'on_' + method . lower ( ) ) ) except AttributeError : pass else : if callable ( responder ) : method_map [ method ] = responder allowed_methods = sorted ( list ( method_map . keys ( ) ) ) if ( 'OPTIONS' not in method_map ) : opt_responder = responders . create_default_options ( allowed_methods ) method_map [ 'OPTIONS' ] = opt_responder allowed_methods . append ( 'OPTIONS' ) na_responder = responders . create_method_not_allowed ( allowed_methods ) for method in HTTP_METHODS : if ( method not in allowed_methods ) : method_map [ method ] = na_responder return method_map
maps http methods to methods of a resource object .