Decorators vs. classes in python web development

后端 未结 2 697
不知归路
不知归路 2021-02-08 11:44

I\'ve noticed three main ways Python web frameworks deal request handing: decorators, controller classes with methods for individual requests, and request classes with methods f

2条回答
  •  广开言路
    2021-02-08 12:21

    The various frameworks are trying to achieve the best performance through the best code (for writing and reading). They each adopt different strategies based on or around MVC or MVT.

    What you're focussing on will probably come down to personal taste. And so will my answer. I'm trying very hard to avoid any sort of holy war because there may be valid technical arguments that I just don't know about.

    But I personally prefer to keep the routing separate from the controller (django's view) and templating separate from that. It makes reusing controllers really simple. Yeah, I'm a Django user.

    As such, I'm really not a big fan of Bottle's decorators or wrapping things in great big hulking classes. I used to when I was an ASP.NET dev but Django set me free.

提交回复
热议问题