News for hackers. Stuff that matters.
Re:A primer on Python decorators by axiak on Wednesday April 11, 2012 @09:54PM (#3830630)
In flask, the app.route decorator mutates the app object. There are no globals necessary. Use of globals to maintain state is an orthogonal issue to use of decorators to update registries.
Re:A primer on Python decorators by gostevehoward on Wednesday April 11, 2012 @10:00PM (#3830650)
Well either the app object is global, in which case you've got global mutable state, or you're defining your handler functions later than module load time, which is pretty uncommon practice.
Re:A primer on Python decorators by wahnfrieden on Thursday April 12, 2012 @12:27AM (#3831023)
You can use the return value of some function as a decorator, as a way to avoid global state and tie the decorator to a given instance of your routing object. (I don't know flask, but this isn't a limitation of python)