Details v Common Python web framework

Source: Internet
Author: User
Tags zend zend framework
Python so many frameworks, can play all over the people are not many, frankly I have only used one of the three development projects, and some slightly touched, so here can only talk about, welcome to the knowledgeable friends to add

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:

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 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.

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:

1 pydanny.blogspot.com/2010/12/stupid-template-languages.html (Requires FQ)
2 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.

Database schema are set for you, so the problem comes, for example, many websites require email address unique, but the schema of the value of this field is not unique, tangled is necessary.

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.

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.

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 R Un (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.


"Recommended"

1. Python Basics Free Tutorial

2. Python Learning Manual

3. Python Object-oriented video tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.