Python Pyramid 简明教程

Python Pyramid - Overview

Pyramid 是用 Python 编写的开源、符合 WSGI 的 Web 框架。最初将该项目命名为 Pylons,但后来以新名称 Pyramid 发行。

Pyramid is an open source, WSGI compliant web framework written in Python. Initially the project named as Pylons, but later released under the new name Pyramid.

  1. Pyramid is a minimalistic web framework. It doesn’t come packaged with any templating library or doesn’t have support for any specific database packages.

  2. However, it can be integrated both with SQL databases via SQLAlchemy and with the Zope Object Database, as well as other NoSQL databases such as CouchDB.

  3. Pyramid can also be configured to work with templating libraries such as Mako, Jinja2 or Chameleon.

  4. Pyramid has been developed by Chris McDonough. The first version of Pyramid was released in January 2011. The latest version, Pyramid 2.0 has been released in March 2021.

Comparison with Other Python Frameworks

Pyramid Web 应用框架受到 Zope 和 Django 框架的启发。因此,它结合了两者的最佳条款。

Pyramid web application framework is inspired by Zope and Django frameworks. As a result, it combines the best provisions of the two.

  1. Pyramid is largely based on repose.bfg framework. After it was merged with the Pylons project, the same was renamed as Pyramid in 2010.

  2. The ability to extend Pyramid application is borrowed from Zope library. Without modifying the application code, the application can be reused, modified or extended. The features such as declarative security layer and traversal of routes is inherited from Zope.

  3. As is the case of Pylons 1.0, Pyramid doesn’t enforce any policy. It also lets the user choose any database or templating system The URL dispatch approach is also inspired by Pylons.

  4. The concept of views is based on similar approach of Django. Extensive documentation is also a Django features adapted by Pyramid.

  5. Although the definition doesn’t fit exactly, Pyramid can be said to follow MVC (Model-View-Controller) approach.