On the five frames of Python web

Source: Internet
Author: User
Tags zend framework

When it comes to Web Framework,ruby, the world of Rails unified, and Python is a world of flowers. Various micro-framework, the framework is innumerable.
Although there is also a large scripting language PHP has a lot of frameworks, but far from Python is so exaggerated, it is 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 the three of the development projects, and some slightly touched, so here only to talk about, welcome to the knowledgeable friends to add.

Django

The Python framework, though, is blossoming. But there's still one big one, and it's Django.

To say Django is the best in the Python framework. Some people are allowed to oppose it. But Django has the best documentation, the highest market share, and the largest number of jobs expected from everyone. The main areas that Django is known for are:

· Perfect documentation for Django's success. I think a big part of this is due to Django's near-perfect official documentation (including Django book).
· A complete solution, Django, like rails, provides a complete solution (Full-stack Framework + batteries included). Basically what you have (for example: cache, session, feed, ORM, GEO, auth). And all Django made it by itself. The tools to develop Web site should also launch Django basically gives you a good one. So the development efficiency is needless to say, out of the problem is also easy to find. It's not in your code, it's in the Django source.


· A powerful URL routing configuration. Django allows you to design a very elegant URL. In Django you are basically able to she used with ugly get.
· Self-service management backend. Admin interface is a more eye-catching contrib in Django, so you almost don't have to write a single line of code to have a full background management interface.


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, assuming that you think a Django built-in feature is not very good. It's very difficult to replace it with a third-party library of your liking. For example, the following will be said Orm, Template. It's almost impossible to use SQLAlchemy or Mako in Django, even if you make some patches, you'll find it very, very awkward.
· Django's own ORM is far less powerful than SQLAlchemy. In addition to the Django Acre, SQLAlchemy is the de facto ORM standard in the Python world, and other frameworks support SQLAlchemy. Only Django still sticks to its own set. The Django Developer's support for SQLAlchemy has also been discussed and tried, but it is finally abandoned, and is expected to be too expensive and difficult to get together with other Django modules.
· The template function is relatively weak, you can not insert Python code, to write a more complex logic need to implement the tag or filter in Python.
· URL configuration Although powerful, but all to handwriting, this is contrary to the concept of rails convention over configuration, the master and the first to know Django the URL will be a very big difference.


· The Tangled auth module, Django's auth, is tightly coupled to other modules. The function is also very strong. is to do a bit too, the user's database schema has been set for you. This is the problem, for example, very many sites require that the email address is unique, but the value of this field in the schema is not unique. Tangled up is a must.
· 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 it is not possible to do so), this is not the embodiment of best practice.


Overall. Django embracing. It is very good to use it to develop some Web applications at high speed.

Assuming you follow Django's design philosophy, you'll think Django is very useful. Instead of assuming that you can't incorporate or accept Django's design philosophy, you'll be very 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

Besides Django, there's a big head that's pylons. Because turbogears2.x is based on pylons. REPOZE.BFG has also been incorporated into Pylons project, where 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 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 all say that pylons is a glue frame designed with glue language.
Choose Pylons more is to choose its freedom, choose the same time of freedom also indicates that you choose a nightmare:
· Learn nightmares. Pylons relies on a lot of 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. Pylons's official documents have been the subject of criticism. Fortunately, the definitive guide to pylons this book, the situation has changed. For this reason. Pylons was once hailed as a Python framework that was only suitable for use by a master.
· Debugging nightmare, due to the number of modules involved, once there is a mistake 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 is only practical and very familiar with the ability to solve problems.
· Upgrade nightmare, install pylons large and small to install nearly 20 Python modules, each with their own version number, to upgrade the pylons version number, which module out of incompatibility problems are possible, upgrade is basically very difficult very difficult.

So far Reddit pylons still stay on the antique 0.9.6, SQLAlchemy also 0.5.3 version number, should be related to 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 it is also a class web.py micro-framework. As the framework of the idea of tornado mainly from the web.py, everyone in the web.py site home can also see Tornado big guy Bret Taylor's such a paragraph (he said here FriendFeed with the framework and Tornado can be regarded 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 for some of the necessary things, such as: URL routing, Template, Access to the database, the others will be handed to the user to do their own.


The advantage of a streamlined framework is that you can focus on the business logic, without too much concern for the framework itself or the interference of the frame, the same time the shortcomings are very obvious, a lot of things you have to self-fencing.
I personally prefer such a streamlined framework. Since you are very easy to figure out how the entire framework works by reading the source code, assume that the frame is not a very agreeable one. I was completely able to monkey patches to my own request.

Bottle & Flask

Bottle and flask as representatives of the new generation Python framework. It's interesting to note that the URL routes are configured in a decorator way, 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 and even all of the code is in the. py file of the Ching line. In addition flask and pylons like, can with JINJA2, sqlalchemy and such combination of very good.


Just now, both bottle and flask success stories are very few.
Quixote
The reason to specifically say Quixote, is due to the largest in the country with the development of Python site "Douban" is developed with Quixote.

I simply flipped through the source code. No research, no comments, and experience to add.

I'm just thinking, suppose Douban is coming to develop now. There should be a lot of other options.
Other (web2py, Uliweb, Karrigell, Werkzeug ...)

finally on the misunderstanding of frame selection
In the framework of the choice of issues, many people are very easy to fall into the following two myths without knowing:

1. Which framework is best -there is no best frame in the world, just the framework that best suits you and the team that best suits you.

Programming language selection is also a good idea, your team Python is the most familiar with Python. Suppose Ruby is the most familiar with Ruby, programming language, framework are just tools, can be many, fast, good, the province of the finished work is a good thing.

2. Pay too much attention to performance -in fact most people are not necessarily too concerned about the performance of the framework. Because you develop the site is a small station, can be 10,000 of the IP site is not much, on 100,000 is very few very little.

It doesn't make much sense to talk about performance before there is a certain amount of access, because your CPU and memory are always idle.

and language and frameworks are generally not a performance bottleneck, and performance issues are most often present 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, are not still able to develop Twitter? In addition to today's hardware, Bandwidth cost is actually very low, especially with the cloud computing platform, the human cost is the most expensive, no tens of thousands of IP at all do not care too much about performance issues, traffic up to spend some money to buy a bit of server space good. Simple, high-speed solution to performance issues.

On the five frames of Python web

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.