When it comes to Web Framework,ruby, the world of Rails unified, and Python is a world of flowers, a variety of micro-framework, the Framework of countless, incomplete list see:
Http://wiki.python.org/moin/WebFrameworks.
Although another big scripting language PHP has a lot of frameworks, but far from Python is so exaggerated, it is precisely because the Python web framework (Python Web Development Framework, hereinafter referred to as the Python framework) too many, So in the Python community there is always a topic about the merits of the Python framework, and the time span of discussion is even 3-5 years.
Python so many frameworks, can play all over the people are not many, frankly I have only used one of the three development projects, others have slightly touched, so here can only talk about, welcome to the knowledgeable friends to add.
Django
The Python framework, though flourishing, is still one of the biggest, and it's Django. To say that Django is the best in the Python framework, some people agree that there is a strong objection, but that Django has the most complete documentation, the highest market share, and the most estimated recruitment positions. The main areas that Django is known for are:
Perfect documentation, Django's success, I think a big part of this is due to Django's near-perfect official documentation (including Django book).
A complete set of solutions, Django, like rails, offers a full suite of solutions (Full-stack Framework + batteries included), basically what's needed (e.g. cache, session, feed, ORM, GEO , auth), and all Django himself made, the development of Web site should also launch tools Django basically give you a good, so the development efficiency is needless to say, out of the problem is also easy to find, not in your code in the Django source.
With a powerful URL routing configuration, Django allows you to design a very elegant URL, and in Django you can basically say goodbye to ugly get parameters.
Self-service admin, admin interface is a more eye-catching contrib in Django, allowing you to have a complete background management interface almost without writing a single line of code.
The main drawback of Django is that Django insists on making all the wheels, the system is relatively closed, and Django's most reviled place is:
The system is tightly coupled, if you feel that the Django built-in feature is not very good, want to use a favorite third-party library to replace is difficult, such as the following will be said Orm, Template. It's almost impossible to use SQLAlchemy or Mako in Django, and even if you make some patches, you'll feel very, very awkward.
Django's own ORM is far less powerful than SQLAlchemy, except in the Django Acre, SQLAlchemy is the de facto ORM standard in the Python world, and other frameworks support SQLAlchemy, But Django still insists on its own set. The Django Developer's support for SQLAlchemy was also discussed and tried, but eventually it was abandoned, and it was estimated to be too expensive and hard to fit with other Django modules.
Template function is weak, can not insert Python code, to write a more complex logic need to use Python to implement the tag or filter. There has been a lot of controversy over the template, and there are two more interesting articles about Python templates that you can refer to in recent years:
- Http://pydanny.blogspot.com/2010/12/stupid-template-languages.html (Requires FQ)
- http://techspot.zzzeek.org/2010/12/04/in-response-to-stupid-template-languages/
The URL configuration is powerful, but it's all about handwriting, which is completely different from the idea of rails ' convention over-configuration, and the URLs that the pros and the people who start with Django will be a big difference.
Tangled auth module, Django auth with other modules tightly, the function is also very strong, is to do a bit over, the user's database schema has been set for you, so the problem comes, for example, many websites require email address only, The value of this field in the schema is not unique, and the tangle is necessary.
Python files do configuration files, rather than the more common forms of INI, XML, or YAML. This is not a problem in itself, but because in theory the value of settings can be changed dynamically (although people do not), this is not the embodiment of best practice.
In general, Django embracing, using it to quickly develop some Web applications is very good. If you follow Django's philosophy of design, you will feel that Django is good to use and more handy, but if you can't incorporate or accept Django's design philosophy, you'll be miserable with Django and give up well. So in some people's eyes, Django is a panacea, but for some people it is poison and poisonous.
pylons & TurboGears & REPOZE.BFG
In addition to Django, another big head is pylons, because turbogears2.x is based on pylons, and REPOZE.BFG has been incorporated into pylons project, TurboGears and REPOZE.BFG are no longer discussed separately.
The design philosophy of pylons and Django is completely different, the pylons itself has only about 2000 lines of Python code, but it also comes with some third-party modules that are almost pylons. Pylons only offers a shelf and optional options, you can freely choose the template, ORM, form, auth and other components according to your preference, the system is highly customizable. We often say that Python is a glue language (glue language), then we can say pylons is a glue language design glue framework.
Choose Pylons more is to choose its freedom, the choice of freedom is also indicative of your choice of nightmare:
Learning nightmares, pylons relies on many third-party libraries, they are not pylons, you learn pylons at the same time you have to learn how to use these libraries, the key sometimes you do not know what you want to learn. Pylons's learning curve is much higher than Django, and the official documents of pylons have been the subject of criticism, but the situation has changed since the definitive guide to pylons. For this reason, pylons was once hailed as a Python framework that was only suitable for use by a master.
Debugging nightmare, because of the number of modules involved, once the error occurs, it is more difficult to locate the problem where. May be you write the program's wrong, it may be pylons error, or sqlalchemy error, do not formencode have a bug, anyway very messy. This problem can only be solved by using it well.
Upgrade nightmare, installation pylons large and small to install nearly 20 Python modules, each with their own version number, to upgrade the version of Pylons, which module is incompatible with the problem is possible, the upgrade is basically difficult. So far Reddit pylons still stay on the antique 0.9.6, SQLAlchemy also is 0.5.3 version, should have relations with this article.
The convergence of pylons and REPOZE.BFG may lead to the next framework that challenges Django status.
Tornado & web.py
Tornado is a Web server (not detailed in this article), At the same time is a class web.py micro-framework, as the framework of the idea of tornado mainly from the web.py, everyone in the web.py website home can also see Tornado of the Big guy Bret Taylor's passage (which he says here FriendFeed with Tornado can be seen as a thing):
"[web.py inspired the] web framework we use for FriendFeed [and] the WebApp framework that ships with APP Engine ..."
Because of this relationship, Tornado is no longer discussed separately.
Web.py's design philosophy is to streamline (Keep it simple and powerful), in total there is not much line of code, and not like pylons rely on a large number of third-party modules, but only to provide a framework necessary for some things, such as: URL routing, Template, Database access, the others are handed to the user to do their own.
The advantage of a streamlined framework is that you can focus on the business logic without much concern about the frame itself or the interference of the frame, and the shortcomings are obvious, and many things you have to do on your own.
I personally prefer this streamlined framework, because you can easily read the source code to understand the whole framework of the working mechanism, if the frame that piece is not very agreeable, I could monkey patch on my own request.
Bottle & Flask
Bottle and flask as representatives of the new generation Python framework, it is interesting to use the decorator way to configure URL routing, such as:
From bottle import route, run @route ('/:name ') def index (name= ' World '): return ' <b> Hello%s!</b> '% name run (host= ' localhost ', port=8080)
Bottle, flask and web.py, are very streamlined, Bottle even all the code in that Ching line of the. py file. In addition flask and pylons like, can with JINJA2, sqlalchemy and such combination of very good.
However, there are still few successful cases, whether bottle or flask.
Quixote
The reason to specifically say Quixote, is because the country's largest use of Python development site "Douban" is developed with Quixote. I simply turned over the source code, did not do research, do not comment, have experience to add. I was just thinking that if douban to develop now, there should be more choices.
Other (web2py, Uliweb, Karrigell, Werkzeug ... )
Finally on the misunderstanding of frame selection
In the framework of the choice of issues, many people can easily fall into the following two myths without knowing:
1. Which framework is best-there is no best framework in the world, only the framework that best suits you and the team that best suits you. Programming language choice is also a reason, your team python is best used python, if the most familiar with Ruby is good, programming language, framework are just tools, can be many, fast, good, the province of the finished work is good things.
2. Pay too much attention to performance-in fact, most people do not need to be too concerned about the performance of the framework, because you develop the site is a small station, to 10,000 of the IP site is not much, on 100,000 is very few. It doesn't make much sense to talk about performance before there is a certain amount of traffic, because your CPU and memory are always idle. Also, language and frameworks are generally not performance bottlenecks, and performance problems are most often seen in database access and file reads and writes. PHP's Zend Framework is famous for its slowness, but the Zend Framework has major stations, such as: Digg.com, Ruby and rails, who are often said to have performance problems, can they still develop Twitter? Moreover now the hardware, the bandwidth cost is actually very low, especially has the cloud computing platform, the manpower cost is the most expensive, does not have tens of thousands of IP at all not to be too concerned about the performance question, the traffic goes up to spend some money to buy the server space to be good, the simple fast solves the performance question.
Note: In front of the netizen questioned me "Quora is developed with pylons" such a statement is not objective, special explanation, here said a site A is developed with B, only refers to a major or part of the development by B, we do not go tangled a also use C.
Original link: http://feilong.me/2011/01/talk-about-python-web-framework
On five Python web frameworks