Configs2026年7月1日·1 分钟阅读

Pyramid — Versatile Python Web Framework for Any Scale

Pyramid is a mature, general-purpose Python web framework that scales from single-file applications to large enterprise systems, offering traversal and URL dispatch routing, pluggable authentication, and deep extensibility.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Pyramid Framework
直接安装命令
npx -y tokrepo@latest install 7b4e6f2d-7569-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Pyramid is a Python web framework from the Pylons Project that is designed to start small and grow with your application. It provides two routing mechanisms (URL dispatch and traversal), a flexible security system, and an extension architecture that allows developers to choose their own ORM, template engine, and session backend.

What Pyramid Does

  • Routes requests via URL dispatch (regex patterns) or traversal (resource trees)
  • Provides a pluggable authentication and authorization policy system
  • Supports view configuration via decorators, imperative calls, or ZCML
  • Offers asset specifications for locating templates, static files, and resources
  • Includes a scaffolding system (cookiecutter templates) for project bootstrapping

Architecture Overview

Pyramid is a WSGI framework built around a Configurator that registers routes, views, and policies. At request time, the router matches a URL to a route or traverses a resource tree, selects the appropriate view callable, applies security predicates, and returns a Response. The framework uses a component architecture (based on Zope interfaces) for extensibility, allowing add-ons to hook into nearly any processing stage.

Self-Hosting & Configuration

  • Requires Python 3.8 or later
  • Install with pip install pyramid or from a cookiecutter template
  • Configuration is done in Python via the Configurator object
  • Deploy with any WSGI server: Gunicorn, uWSGI, or Waitress (included)
  • Use pserve development.ini during development for auto-reload

Key Features

  • Dual routing system: URL dispatch for REST APIs, traversal for content-heavy apps
  • Security policies are pluggable and decoupled from views
  • Extensible via add-ons that hook into the configurator without monkey-patching
  • First-class support for internationalization and localization
  • Comprehensive test harness with pyramid.testing for unit and functional tests

Comparison with Similar Tools

  • Django — opinionated full-stack with built-in ORM; Pyramid is choose-your-own-components
  • Flask — micro framework for simple apps; Pyramid scales better to complex architectures
  • FastAPI — async-first API framework; Pyramid is WSGI-based with deeper extensibility
  • Tornado — async server with its own event loop; Pyramid runs on standard WSGI servers
  • web2py — batteries-included with admin UI; Pyramid favors explicit configuration

FAQ

Q: When should I choose Pyramid over Django? A: Choose Pyramid when you need flexibility in component selection (ORM, template engine) or when your routing needs go beyond simple URL patterns (traversal).

Q: Does Pyramid support async views? A: Pyramid 2.0 added initial async view support. For fully async applications, consider pairing with an ASGI adapter or using a dedicated async framework.

Q: What is traversal routing? A: Traversal walks a tree of resource objects using URL path segments as keys. It is useful for CMS-like applications where URL structure mirrors a content hierarchy.

Q: Is Pyramid still actively maintained? A: Yes. The Pylons Project maintains Pyramid with regular releases and security patches.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产