Which is the WEB framework for Odoo projects: 12 Python web frameworks, how many have you used?

12 Python web frameworks, how many have you used

 Python, as a glue language, has become highly sought after with the advent of the AI era. It has many development directions, such as: web scraping, data analysis, automated testing, artificial intelligence, operations, and web development.

Python programmers have many great choices for creating web applications and APIs; Django, Weppy, Bottle, and Flask lead the way.

If you are developing a web application and have chosen Python as the language to build it, then this is a wise choice. Python's development maturity, powerful libraries, and wide range of practical applications make it essential for web development.

Actually, Python web development may not be as prevalent in China, but it has been growing rapidly abroad. Some well-known domestic websites, such as Zhihu, NetEase, and Douban, are developed using Python; internationally, there are Quora (a social Q&A website), Google, and Pinterest (a visual discovery and sharing platform).

So, today I’m sharing 12 well-known Python web frameworks.

1.Django

Django is an open-source web application framework written in Python that supports many database engines, enabling rapid and scalable web development, with continuous version updates to match the latest Python versions. If you are a novice programmer, you can start with this framework.

The main aspects for which Django is praised are:

Perfect documentation. A large part of Django's success can be attributed to its nearly perfect official documentation.

2. Complete solution: Django provides a complete solution, basically offering everything you need, and it's all built by Django itself. The tools needed for developing websites are mostly ready-made in Django, so development efficiency goes without saying. When problems arise, they are also relatively easy to locate—either in your code or in Django's source code.

3. Powerful URL routing configuration allows you to design very elegant URLs in Django, where you can basically say goodbye to ugly GET parameters.

4. Self-service admin backend, the admin interface is one of the most eye-catching contribs in Django, allowing you to have a complete backend management interface without writing almost a single line of code.

5. The system is tightly coupled. If you feel that a certain built-in feature of Django is not very good, it is very difficult to replace it with a preferred third-party library, such as the ORM and Template mentioned below. It is almost impossible to use SQLAlchemy or Mako in Django, and even if you apply some patches to make them work, it will feel very, very awkward.

6. The Template functionality is relatively weak; it cannot insert Python code, and implementing more complex logic requires writing Tags or Filters in Python separately.

Django follows a comprehensive approach, focusing on efficient development. It is best known for its fully automated admin backend: simply use its ORM to define objects, and it will automatically generate the database structure and a full-featured admin backend.

2.CubicWeb

CubicWeb is described as "a semantic web application framework that supports reuse and object-oriented design." It is an interesting system that emphasizes the use of abstract and reusable code blocks called "cubes," but may be too abstract or specialized for some developers.

A multidimensional dataset is a software component with schemas (data models), entities (programming logic), and views. By combining multiple cubes, each performing its own task, software applications can be written by reusing one's own code and other code.

3.Web2py

Web2py is a free and open-source web framework written in Python, designed for agile and rapid development of web applications. It features fast, scalable, secure, and portable database-driven applications, and follows the LGPLv3 open-source license.

Web2py provides an all-in-one solution, allowing the entire development process to be carried out in a browser. It offers web-based online development, HTML template writing, static file upload, and database writing capabilities. Other features include logging functionality and an automated admin interface.

4.Weppy

Weppy feels like a middle ground between Flask's minimalism and Django's completeness. While developing Weppy applications has the straightforwardness of Flask, Weppy includes many features from Django, such as a data layer and authentication. Therefore, Weppy is suitable for applications ranging from extremely simple to moderately complex.

5.Zope2

Zope is not suitable for simple RESTful APIs (like Bottle or Flask), nor is it suitable for basic interactive websites (à la Django). Instead, it is intended to be a complete enterprise-level application server stack, similar to Java products. The documentation describes the framework as "most useful for component developers, integrators, and web designers." A major third-party product, the Plone CMS, uses Zope as its foundation and serves as the primary driving force behind Zope's ongoing development.

6.Bottle

Bottle is a simple and efficient micro Python web framework that follows WSGI. It is called micro because it consists of only one file and does not depend on any third-party modules except for the Python standard library.

Bottle can be considered a mini Flask because it is more compact and concise than other "micro-frameworks". Due to its minimal footprint, Bottle is well-suited for embedding in other projects or quickly delivering small projects like REST APIs.

7.CherryPy

CherryPy is a simple yet highly useful web framework for Python, primarily designed to connect a web server with Python code with minimal effort. Its features include built-in profiling, a flexible plugin system, and the ability to run multiple HTTP servers simultaneously, and it is compatible with the latest versions of Python, Jython, and Android.

8.Falcon

If you are building a REST-based API rather than anything else, Falcon provides exactly what is necessary. Its design is streamlined and fast, with almost no dependencies outside the standard library.

The reason Falcon has earned the "lightweight" label is largely unrelated to the number of lines of code in the framework. This is because Falcon imposes almost no structure on the application.

Falcon also adopts sensible out-of-the-box default settings, so almost no modifications are needed during installation.

Falcon's focus on APIs means that building web applications with traditional HTML user interfaces is almost nonexistent.

Falcon's documentation is more concise compared to other frameworks, but only because its scope is smaller. The user guide includes formal step-by-step walkthroughs of all major features, along with a quickstart section that lets you view example code with or without annotations.

9.Flask

Flask is a lightweight web application framework written in Python. It is based on the Werkzeug WSGI toolkit and the Jinja2 template engine, and is licensed under BSD.

Flask is also known as a "microframework" because it uses a simple core and adds other functionality through extensions. Flask does not have a default database or form validation tool. However, Flask retains the flexibility for expansion, allowing these features to be added via Flask-extensions: ORM, form validation tools, file uploads, and various open authentication technologies.

Flask is very lightweight, allowing you to develop a simple website at a low cost. It is very suitable for beginners to learn. After learning the Flask framework, you can consider learning how to use plugins. For example, use WTForm + Flask-WTForm to validate form data, and use SQLAlchemy + Flask-SQLAlchemy to control your database.

Flask is lightweight, but highly extensible (with over 37,000 stars on GitHub, it's clear that the crowd's choice is justified), allowing us to customize specific features during development.

10.Pyramid

Pyramid is a very versatile open-source web framework. As a framework, its primary task is to make it easy for developers to create web applications. The type of web application doesn't matter; it could be an electronic form, an intranet, or a social platform. Pyramid is very versatile and can be used in a wide variety of situations.

Small and lightweight, Pyramid is closer to Flask or even Falcon than Django. Therefore, it is well-suited for exposing existing Python code as REST APIs, or for providing the core tasks of web projects where most of the heavy lifting is done by developers.

Pyramid supports Python 2 and Python 3, but does not use Python 3's asynchronous syntax.

11.Tornado

Tornado is a powerful, extensible web server written in Python. It is robust enough to handle severe network traffic, yet lightweight enough to create and write, and can be used in a wide range of applications and tools.

Features of Tornado:

As a web framework, it is a lightweight web framework similar to another Python web framework, Web.py, and it features an asynchronous non-blocking I/O processing approach.

As a web server, Tornado has relatively excellent load resistance. The official deployment compared Tornado with other Python web application frameworks using nginx reverse proxy, and the result showed that its maximum page views exceeded the second place by nearly 40%.

Tornado follows a lean and efficient approach, focusing on superior performance, and it is best known for its asynchronous non-blocking design.

12.Wheezy.web

Wheezy.web is a Flask/Bottle/Pyramid model of web frameworks: small and lightweight, focused on providing high speed and high concurrency. The core feature set is small, but its creator has equipped it with various essential functions.

Wheezy's development seems to have stalled, as the project's last commits were recorded in 2015. This does not bode well for maintaining compatibility with new Python features.

Summary:

Above we analyzed 12 frameworks. Five of them: Django, CubicWeb, Web2py, Weppy, and Zope2, adopt a "batteries-included" approach, containing most of the features you can imagine needed for a web application. The remaining seven frameworks: Bottle, CherryPy, Falcon, Flask, Pyramid, Tornado, and Wheezy.web, offer a more minimalist appearance, trading off comprehensiveness and completeness for simplicity and ease of use.

Misconceptions about framework selection:

Regarding the choice of frameworks, many people easily fall into the following two misconceptions without realizing it: Which framework is the best? There is no best framework in the world, only the one that best suits you and your team. The same principle applies to programming language selection. If your team is most familiar with Python, then use Python; if you are most familiar with Ruby, then use Ruby. Programming languages and frameworks are just tools. As long as they help you get the job done more efficiently, quickly, well, and cost-effectively, they are good tools.

Overemphasis on performance—in reality, most people don't need to worry too much about a framework's performance, because the websites you develop are mostly small sites. There aren't many sites that can reach 10,000 IPs, and even fewer that reach 100,000. Discussing performance without a certain level of traffic is actually meaningless, because your CPU and memory are just sitting idle.

 

关于我们

​我们致力于帮助中小企业实现数字化转型,我们的团队由一群充满激情和创新思维的专业人士组成,他们具备丰富的行业经验和技术专长。

扫一扫获取顾问以及手册

归档
Sign in to leave a comment
Odoo Development Beginner's Manual: Do You Know How to Use These Odoo Development Methods
Odoo Development Beginner's Manual