chain of responsibility pattern def handle_request(selfrequestresponse=none)user user get_verified_user(request['username']request['password']request['user'user return self next_handler handle_request(requestresponseclass pathhandler(object)def __init__(self)self next_handler endhandler(def handle_request(selfrequestresponse=none)path request["path_info"split("/"if "goodbyein pathresponse "goodbye {}!format(request['user'nameelseresponse "hello {}!format(request['user'namereturn self next_handler handle_request(requestresponsedef application(envstart_response)head authorizationhandler(current head current next_handler userhandler(current current next_handler current next_handler pathhandler(start_response(' ok'[('content-type''text/html')]return [head handle_request(env)another alternative implementation of the chain of responsibility pattern is to instantiate main object to dispatch handlers from list passed into the dispatcher on instantiation