(Full disclosure: I'm a member of Django's core team) There's no single "best" for every application. One-size-fits-none. One of Django's strengths is in the fact that parts of the framework come off easily when they no longer serve your needs. If the ORM is no longer working for you, you can use SQLAlchemy or write raw SQL. Authentication no longer working for you? Write your own or use a 3rd party one. Et cetera. T…
Ask HN: Best Python web framework
71–80 of 110 posts
Re: Ask HN: Best Python web framework
#72Here's my answer on stackoverflow early last year when someone asked for a CherryPy vs Flask comparison. I believe all the points still stand and still represent CherryPy's strengths.
1. Simplicity. Controller object trees more or less equal to how you would define your URLs. 2. Flexibility. In case you don't like how the URLs are defined by default, you can use routes or methods to expose your URL handlers, which are just as easy. 3. Tools. CherryPy isn't religious about WSGI, though it's 100% compatible with the WSGI spec, the recommended approach is to use Tools. They are simple to make and use, and the way they are wired to the request is a lot more efficient than WSGI, which typically a request has to pass through whether or not that particular WSGI middleware is relevant. (Unless you use a framework where each URL handler is a WSGI application, but wiring up WSGI apps are still annoying). There are LOTS of them supplied by default that cover most of the use cases you can think of. 4. Plugins. For cross-cutting concerns, engine plugins are a much more granular, well-defined, and suitable way to deal with them as opposed to a WSGI app, which is typically the hammer people use to hammer in every screw these days. 5. Easy chunked responses. You just yield a string in the controller and that's it. Very useful for returning large documents in pieces. 6. Full-featured request and response objects. WebOb and CherryPy are about the only 2 frameworks that have comparably complete implementations of them, but I'd still choose CherryPy for the last reason: 7. Zero dependency on other packages. You won't bring in a dozen other libraries just to run a server. You just easy_install or pip install cherrypy and that's it.
Its WSGI server is also the canonical choice if you need a fast and stable pure Python WSGI server implementation. It's actually really really fast and stable:
http://nichol.as/benchmark-of-python-web-servers
Now, I've been using CherryPy for about 5 years now and am still absolutely in love with it. I love it so much that I've decided last month to open source the micro-framework I've built on top of CherryPy called BlueberryPy: https://bitbucket.org/wyuenho/blueberrypy
It's basically a set of additional tools and plugins for CherryPy which give you an easier integration with SQLAlchemy, logging, Redis and Jinja2, webassets and various other goodies. It also comes with a project skeleton generator akin to many other frameworks out there but doesn't get in your way with the generated source files. All that BlueberryPy asks for is a configuration directory with a few correct YAML config files with a few keys pointing to a few classes in your package. Documentation is a little light but more will come soon enough as I find time to finish them up. Stay tuned :PRe: Ask HN: Best Python web framework
#73The slides are at http://www.slideshare.net/r1chardj0n3s/web-microframework-ba... -- they don't seem to be loading inline now but the PDF download still works. Video of the talk is at http://www.youtube.com/watch?v=AYjPIMe0BhA .
Spoiler alert: the winner was bottle.py, by a nose.
Re: Ask HN: Best Python web framework
#74web2py is great. Really. I'm quite sure some people are confusing web.py (toolkit behind reddit) and web2py - I know I was a couple of years ago. web2py is super complete, but doesn't get in your way, and doesn't require you to learn everything up front. It's DAL is much simpler (and in my opinion, much more effective) than an ORM -- but you don't have to use it. Its templating system is just plain python inside {{}}…
Quite unlikely, they'd probably have far more praises for it if they did confuse them.
Re: Ask HN: Best Python web framework
#75web2py is great. Really. I'm quite sure some people are confusing web.py (toolkit behind reddit) and web2py - I know I was a couple of years ago. web2py is super complete, but doesn't get in your way, and doesn't require you to learn everything up front. It's DAL is much simpler (and in my opinion, much more effective) than an ORM -- but you don't have to use it. Its templating system is just plain python inside {{}}…
Re: Ask HN: Best Python web framework
#76Richard Jones did a nice presentation about this in August 2011, comparing 10 Python frameworks along a lot of useful metrics (perf, simplicity, size, documentation, etc) by developing the same "hello world"-ish app in each one. He even scored them at the end. The slides are at http://www.slideshare.net/r1chardj0n3s/web-microframework-ba... -- they don't seem to be loading inline now but the PDF download still works.…
Re: Ask HN: Best Python web framework
#77Try Brubeck. It's a Python web framework built around Gevent, DictShield and ZeroMQ. It communicates with Mongrel2, it's web server, via ZeroMQ sockets so even the annoying design of WSGI is moved out of the way. It converts your blocking calls to nonblocking, has no spaghetti code filled with callback shenanigans, and can even generate a full REST API for you. https://github.com/j2labs/brubeck
Re: Ask HN: Best Python web framework
#78Richard Jones did a nice presentation about this in August 2011, comparing 10 Python frameworks along a lot of useful metrics (perf, simplicity, size, documentation, etc) by developing the same "hello world"-ish app in each one. He even scored them at the end. The slides are at http://www.slideshare.net/r1chardj0n3s/web-microframework-ba... -- they don't seem to be loading inline now but the PDF download still works.…
Re: Ask HN: Best Python web framework
#79The project is a web interface for our library's digital archives (mostly audio and video assets, but also images and print documents). Version 1 of the project used php and mysql for the front end with python scripts handling the transcoding and metadata handling on the back end. For a variety of reasons the project got bloated to the point of being unmanageable. I decided I wanted a fresh start with a python framework and considered all the ones mentioned here.
I went with Flask because I wanted to leave the existing database structure in place and I wanted to err on the side of the framework doing too little instead of too much.
As a non-programmer (my job title says "audio engineer"), Flask was simple enough to understand, but did enough to make my life considerably easier. My one gripe is I think Flask-Login still has room for improvement, at least in terms of documentation. I've gotten it working good enough, but I still don't understand how credentials are passed around my application.
I'm sure other frameworks would have also gotten me to where I needed to be, but after working with Flask for a month or so, I'm not immediately reaching for something else.
Re: Ask HN: Best Python web framework
#80Earlier quoted context omitted.
Disagree, Django Rest Framework and TastyPie make REST APIs effortless: write Django models, register them with the REST plugin, hook the plugin to your main URL structure. They're a really good example of how Django enables reuse. Implementation-wise they both hook into the model framework and the form framework, although you can swap out those parts if your data lives elsewhere.
I see what you're saying. But I disagree that: Database = Model = Resource