Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

My app is growing from small to medium and I'm adding functions that should get reviewed.

My routing is:

routes = [
        (r'/', CyberFazeHandler),
        (r'/vi/(eyes|mouth|nose)', CyberFazeHandler),
        (r'/realtime', RealtimeHandler),
        (r'/task/refresh-user/(.*)', RefreshUserHandler),
        ('/ai', FileUploadFormHandler),
        ('/serve/([^/]+)?', ServeHandler),
        ('/upload', FileUploadHandler),
        ('/generate_upload_url', GenerateUploadUrlHandler),
        ('/file/([0-9]+)', FileInfoHandler),
        ('/file/set/([0-9]+)', SetCategoryHandler),
        ('/file/([0-9]+)/download', FileDownloadHandler),
        ('/file/([0-9]+)/success', AjaxSuccessHandler),
        ]

app = webapp2.WSGIApplication(routes,
            debug=os.environ.get('SERVER_SOFTWARE', '').startswith('Dev'
            ))

Does it look alright to you? Can you recommend an improvement? Should I use the 'r prefix to my regexes?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Have you considered using named Route templates instead of capturing regular expressions? It could make the code more readable. Consider

Route("/task/refresh-user/<username>", RefreshUserHandler)

instead of

(r'/task/refresh-user/(.*)', RefreshUserHandler)

for example. (Of course, I don't know what kwargs RefreshUser actually wants, but you can change the angle-bracketed part to the appropriate name.)

share|improve this answer
1  
Thanks! The suggestion would definitely have the advantages of improving readibility and maintainability. –  Programmer 400 Nov 9 '11 at 9:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.