<s> """<STR_LIT>""" <EOL> from tornado . web import URLSpec <EOL> class Route ( object ) : <EOL> """<STR_LIT>""" <EOL> _routes = [ ] <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , route , initialize = { } , name = None , host = "<STR_LIT>" ) : <EOL> self . route = route <EOL> self . initialize = initialize <EOL> self . name = name <EOL> self . host = host <EOL> def __call__ ( self , handler ) : <EOL> """<STR_LIT>""" <EOL> name = self . name or handler . __name__ <EOL> spec = URLSpec ( self . route , handler , self . initialize , name = name ) <EOL> self . _routes . append ( { '<STR_LIT:host>' : self . host , '<STR_LIT>' : spec } ) <EOL> return handler <EOL> @ classmethod <EOL> def routes ( cls , application = None ) : <EOL> """<STR_LIT>""" <EOL> if application : <EOL> for route in cls . _routes : <EOL> application . add_handlers ( route [ '<STR_LIT:host>' ] , route [ '<STR_LIT>' ] ) <EOL> else : <EOL> return [ route [ '<STR_LIT>' ] for route in cls . _routes ] </s>
