Talking about five Python Web frameworks and five pythonweb

Source: Internet
Author: User
Tags install django

Talking about five Python Web frameworks and five pythonweb

Speaking of the Web Framework, the world of Ruby Rails is a uniform world, while Python is a colorful world. For a variety of micro-frameworks and frameworks, see:

Http://wiki.python.org/moin/webframeworks.

Although PHP, another major scripting language, also has many frameworks, it is far less exaggerated than Python. It is precisely because there are too many Python Web frameworks, in the Python community, there is always a topic about the advantages and disadvantages of the Python framework. The discussion may take up to three to five years.

There are not many people playing with so many Python frameworks one by one. Frankly speaking, I have only used three of them for development projects, and some others have been slightly touched, so we can only talk about it here. Thank you for your understanding.

Django

Although the Python framework is full of flowers, the biggest one is Django. I would like to say that Django is the best in the Python framework, and some people agree that some people are also opposed to it. However, it is said that Django has the most comprehensive documentation, the highest market share, and most recruitment positions. I don't have any comments. Django is hailed mainly as follows:

The perfect document is Django's success. I think most of the reason is due to Django's almost perfect official documentation (including Django book ).

A full set of solutions. Like Rails, Django provides a full set of solutions (full-stack framework + batteries supported DED). What are the basic requirements? (For example: cache, session, feed, orm, geo, auth), and all created by Django. The tools for developing the ingress on the website are basically ready for you, so the development efficiency is needless to say, if something goes wrong, you can find it. If it is not in your code, it is in the Django source code.

With powerful URL routing configuration, Django allows you to design very elegant URLs. In Django, you can say goodbye to ugly GET parameters.

The admin interface is A contrib that is eye-catching in Django, allowing you to have a complete background management interface without having to write a line of code.

The disadvantage of Django mainly comes from Django's insistence on making all its own wheels, and the entire system is relatively closed. The most criticized parts of Django are:

The system is tightly coupled. If you think that a built-in function of Django is not very good, it is very difficult to replace it with a third-party library you like, such as The ORM and Template mentioned below. It is almost impossible to use SQLAlchemy or Mako in Django. Even if some patches are used, it will make you feel very awkward.

The built-in ORM of Django is far less powerful than SQLAlchemy. Apart from Django, SQLAlchemy is the de facto ORM standard in the Python world. Other frameworks support SQLAlchemy, django only sticks to its own set. Django developers have discussed and tried SQLAlchemy's support, but they finally gave up. It is estimated that the cost is too high and it is difficult to integrate with other modules of Django.

The Template function is weak and cannot insert Python code. To write complicated logic, you must use Python to implement Tag or Filter. There has been a lot of debate on templates. Recently, there are two interesting articles about Python templates for your reference:

 

Although the URL configuration is powerful, it must be written by hand. This is completely different from the concept of Rails Convention over configuration. There is a big difference between a master and a user who first knows Django.

The tangle of auth modules, Django's auth is closely integrated with other modules, and features are quite strong, that is, it is a bit too much, your database schema has been set for you, this problem arises. For example, many websites require that the email address be unique, but the value of this field in the schema is not unique and Tangle is necessary.

Python files are used as configuration files, rather than more common ini, xml, or yaml formats. This is not a problem in itself, but theoretically, the value of settings can be dynamically changed (although not everyone can do this), but this is not the embodiment of the best practice.

In general, it is good to use Django to quickly develop some Web applications. If you follow Django's design philosophy, you will feel that Django is easy to use. On the contrary, if you cannot integrate or accept Django's design philosophy, it will be very painful for you to use Django. So in some people's eyes, Django is no different from xiandan, but for some people, it is a poison and highly toxic.

Pylons&TurboGears&Repoze. bfg

In addition to Django, the other big data is Pylons, because TurboGears2.x is based on Pylons, and repoze. bfg has also been incorporated into this big project in the Pylons project. We will not discuss TurboGears and repoze separately later. bfg.

Pylons and Django have different design concepts. Pylons only has about two thousand lines of Python code, but it also comes with some third-party modules that are almost used by Pylons. Pylons provides only one rack and an optional solution. You can choose Template, ORM, form, auth, and other components based on your preferences. The system is highly customizable. We often say that Python is a glue language, so we can say that Pylons is a glue framework designed by the glue language.

The choice of Pylons is mostly about freedom. The choice of freedom also indicates that you have chosen a nightmare:

Learning from the nightmare, Pylons depends on many third-party libraries, which are not made by Pylons. You still have to learn how to use these libraries when learning Pylons. Sometimes you don't know what you want to learn. Pylons has a higher learning curve than Django, and Pylons's official documents have been The object of criticism. Fortunately, The Definitive Guide to Pylons was published later, this situation has changed. For this reason, Pylons was once hailed as a Python framework suitable for masters.

Debugging is a nightmare because many modules are involved. Once an error occurs, it is difficult to locate the problem. It may be because the program you wrote is wrong, Pylons is wrong, or SQLAlchemy is wrong. If the formencode has a bug, it is messy. This problem can be solved only when you are familiar with it.

In the nightmare of upgrading to Pylons, nearly 20 Python modules are required to be installed. Each module has its own version number. to upgrade the version of Pylons, any module with incompatibility issues may occur, upgrading is basically difficult. So far, the Pylons of reddit remains on the antique 0.9.6, and SQLAlchemy is also in version 0.5.3, which should be related to this article.

The integration of Pylons and repoze. bfg may lead to the next framework that can challenge Django's position.

Tornado&Web. py

Tornado is a Web server (not described in this article) and a web-like. py micro-framework, as the idea of Tornado framework, mainly comes from Web. py. on the page of py's website, you can also see such a paragraph of Bret Taylor, the big guy of Tornado (the framework used by FriendFeed and Tornado here can be seen as a thing ):

"[Web. py got red the] Web framework we use at FriendFeed [and] the webapp framework that ships with App Engine ..."

Due to this relationship, Tornado will not be discussed separately later.

Web. py's design philosophy is to streamline it simple and powerful. There is not much code in total, nor is it dependent on a large number of third-party modules as Pylons does, instead, we only provide some things necessary for a framework, such as URL routing, Template, and database access. The rest is done by the user.

The advantage of streamlining a framework is that you can focus on the business logic without worrying too much about the framework itself or the framework's interference. At the same time, the disadvantages are also obvious, you have to handle many things on your own.

I personally prefer this streamlined framework because you can easily understand the working mechanism of the entire framework by reading the source code. If the framework is not quite satisfactory, I can patch Monkey as per my own requirements.

Bottle&Flask

Bottle and Flask are representative of the Python framework of the new generation. It is interesting that they all adopt the decorator method to configure URL routing, such:

from bottle import route, run @route('/:name')def index(name='World'):    return '<b>Hello %s!</b>' % name run(host='localhost', port=8080)

Like web. py, Bottle and Flask are all very simple. Bottle and even all the Code are in that two thousand-line. py file. In addition, like Pylons, Flask can be well combined with Jinja2 and SQLAlchemy.

However, at present, there are few successful cases, either Bottle or Flask.

Quixote

Quixote is the largest Chinese website "doubannet" developed using Python. I simply flipped through the source code, did not do research, did not post comments, and experienced to add. I was just thinking that if Douban.com is handed over to the present for development, there should be more options.

Others (web2py, uliweb, Karrigell, Werkzeug ...)

Finally, misunderstandings about framework Selection

With regard to the choice of frameworks, many people may easily fall into the following two misunderstandings:

1. Which framework is the best? There is no best framework in the world. Only the framework that best suits you and your team. Programming Language selection is also a truth. Your team's Python is the most familiar with Python. If you are familiar with Ruby, you should use Ruby. The programming language and framework are only tools, being able, fast, good, and saving is good.

2. focusing too much on performance-in fact, most people do not have to worry too much about the performance of the framework, because the website you develop is basically a small site, and there are not many websites with 10 thousand IP addresses, there are very few of the top 0.1 million. It doesn't make much sense to talk about performance without a certain amount of traffic, because your CPU and memory are always idle. In addition, languages and frameworks are generally not performance bottlenecks, and performance problems most often occur in database access and file read/write. PHP's Zend Framework is notoriously slow, but Zend Framework also has many websites, such as digg.com. It is often said that Ruby and Rails with performance problems, can I still develop twitter? In addition, the current hardware and bandwidth costs are actually very low. Especially with the cloud computing platform, the labor cost is the most expensive. Without tens of thousands of IP addresses, you don't have to worry too much about performance issues, when the traffic goes up, it takes some time to buy some server space, which can solve performance problems easily and quickly.

Note: Some netizens have questioned that the saying "Quora is developed with Pylons" is not objective. Specifically, A website A is developed with B, it only means that the main or part of A is developed by B, so don't tangle with A and use C again.

Link: http://feilong.me/2011/01/talk-about-python-web-framework


Which of the following python web frameworks is easier to use and easier to use?

Not very clear.
I only know that django is widely used.

The following documents are for reference:
I sorted out:
[Arrangement] common Web frameworks in Python

I am tossing django's:
[Record] install Django
[Record] After installing Django on the official website through pip, toss the first Django app
[Record] After installing Django on the official website through pip, toss the second Django app

Does Python also have a web development framework?

It is often too many, and several are recommended, including django, flask, bottle, and web. py.
 

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.