3 ms·
Medium to large Django projects were the first times that I began to see the power and usefulness of decorators. The most useful one I've used was a decorator t
by chairmanwow 9y ago
Medium to large Django projects were the first times that I began to see the power and usefulness of decorators. The most useful one I've used was a decorator to require certain JSON parameters in a POST and optionally specify a list of possible parameters. Makes the API code logic infinitely simpler, especially if you write some custom middleware to handle / report API errors. The code is clear and declarative, and errors are handled gracefully all in one place.
- dozzie 9y agoWhich is very funny, because you'd get the same without decorators by simply using properly defined RPC protocol instead of ad hoc developed entangled mess that passes as REST.
- icebraining 9y agoYou still have to define the procedures to use with the protocol using language features - like decorators. For example: http://spyne.io/docs/2.10/reference/decorator.html http://spyne.io/docs/2.10/reference/decorator.html