Pyramid Web アプリケーション開発フレームワーク¶
Pyramid は、小さく、速く、堅実 (down-to-earth) な Python ウェブ アプリケーション開発フレームワークです。 Pyramid は Pylons プロジェクトの 一部として開発されています。 BSD-like なライセンス の下でライセンスされています。
最も単純な Pyramid アプリケーションはこのようになります:
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello %(name)s!' % request.matchdict)
if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/hello/{name}')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
Pyramid をインストールしてアプリケーションを起動した後で、
ブラウザで http://localhost:8080/hello/world
を訪れれば、
Hello, world!
というテキストが見えるはずです。
このアプリケーションがどのようにして動くのかについての完全な説明は、 はじめての Pyramid アプリケーションを作る を参照してください。 Pyramid がこの ような単純なアプリケーションから非常に大きなウェブアプリケーションまで スケールするためにどのように設計されているかを理解するには マニュアル を読んでください。
What’s New¶
マニュアル¶
Pyramid を使用する方法について説明した、章形式のマニュアル (Narrative documentation) です。
- Pyramid イントロダクション
- Pyramid のインストール
- はじめての Pyramid アプリケーションを作る
- アプリケーション設定
- Creating a Pyramid Project
- Scaffolds Included with Pyramid
- Creating the Project
- Installing your Newly Created Project for Development
- Running The Tests For Your Application
- Running The Project Application
- Viewing the Application
- The Project Structure
- The
MyProject
Project
- The
myproject
Package
- Modifying Package Structure
- Using the Interactive Shell
- What Is This
pserve
Thing - Using an Alternate WSGI Server
- Startup
- リクエスト処理
- URL Dispatch
- High-Level Operational Overview
- Route Configuration
- Route Matching
- Routing Examples
- Matching the Root URL
- Generating Route URLs
- Static Routes
- Redirecting to Slash-Appended Routes
- Debugging Route Matching
- Using a Route Prefix to Compose Applications
- Custom Route Predicates
- Route Factories
- Using Pyramid Security With URL Dispatch
- Route View Callable Registration and Lookup Details
- References
- ビュー
- レンダラー
- Templates
- Using Templates Directly
- System Values Used During Rendering
- Templates Used as Renderers via Configuration
Chameleon
ZPT Templates- Templating with
Chameleon
Text Templates - Side Effects of Rendering a Chameleon Template
- Debugging Templates
Chameleon
Template Internationalization- Templating With Mako Templates
- Automatically Reloading Templates
- Available Add-On Template System Bindings
- View Configuration
- Static Assets
- Request and Response Objects
- Sessions
- Using Events
- Environment Variables and
.ini
File Settings- Reloading Templates
- Reloading Assets
- Debugging Authorization
- Debugging Not Found Errors
- Debugging Route Matching
- Preventing HTTP Caching
- Debugging All
- Reloading All
- Default Locale Name
- Including Packages
- Explicit Tween Configuration
- Mako Template Render Settings
- Examples
- Understanding the Distinction Between
reload_templates
andreload_assets
- Adding A Custom Setting
- Logging
- PasteDeploy Configuration Files
- Command-Line Pyramid
- Internationalization and Localization
- Creating a Translation String
- Working With
gettext
Translation Files - Using a Localizer
- Obtaining the Locale Name for a Request
- Performing Date Formatting and Currency Formatting
- Chameleon Template Support for Translation Strings
- Mako Pyramid I18N Support
- Localization-Related Deployment Settings
- “Detecting” Available Languages
- Activating Translation
- Locale Negotiators
- Virtual Hosting
- 単体テスト、結合テスト、機能テスト
- リソース
- Hello Traversal World
- トラバーサルの空騒ぎ
- Traversal
- Security
- Enabling an Authorization Policy
- Protecting Views with Permissions
- Assigning ACLs to your Resource Objects
- Elements of an ACL
- Special Principal Names
- Special Permissions
- Special ACEs
- ACL Inheritance and Location-Awareness
- Changing the Forbidden View
- Debugging View Authorization Failures
- Debugging Imperative Authorization Failures
- Creating Your Own Authentication Policy
- Creating Your Own Authorization Policy
- Combining Traversal and URL Dispatch
- Invoking a Subrequest
- フックの使用
- Not Found ビューの変更
- Forbidden View の変更
- リクエストファクトリの変更
- Before Render イベントの使用
- レンダラーグローバルの追加 (非推奨)
- レスポンスコールバックの使用
- finished コールバックの使用
- トラバーサーの変更
pyramid.request.Request.resource_url()
の URL 生成方法の変更- Pyramid がビューレスポンスを扱う方法の変更
- ビューマッパーの変更
- 設定デコレータの登録
- “tween” の登録
- Adding A Third Party View, Route, or Subscriber Predicate
- Pyramid Configuration Introspection
- 既存の Pyramid アプリケーションの拡張
- 高度な設定
- Pyramid Configurator の拡張
- Creating Pyramid Scaffolds
- Upgrading Pyramid
- Thread Locals
- Pyramid で Zope コンポーネントアーキテクチャを使う
チュートリアル¶
様々なタイプのアプリケーションを構築するために Pyramid を使用 する方法や、 Pyramid アプリケーションを様々なプラットフォームへ 展開する方法について説明したチュートリアルです。
API Documentation¶
すべての Pyramid API に対するドキュメント
- API Documentation
pyramid.authorization
pyramid.authentication
pyramid.compat
pyramid.config
pyramid.decorator
pyramid.events
pyramid.exceptions
pyramid.httpexceptions
pyramid.i18n
pyramid.interfaces
pyramid.location
pyramid.paster
pyramid.path
pyramid.registry
pyramid.renderers
pyramid.request
pyramid.response
pyramid.scaffolds
pyramid.scripting
pyramid.security
pyramid.session
pyramid.settings
pyramid.static
pyramid.testing
pyramid.threadlocal
pyramid.traversal
pyramid.tweens
pyramid.url
pyramid.view
pyramid.wsgi
設計ドキュメント¶
サンプルアプリケーション¶
cluegun は、 Rocky Burt の ClueBin を基にした単純な pastebin アプリケーションです。 Pyramid アプリケーションでの フォーム処理、セキュリティ、 ZODB の使用を実証します。 次のようにしてこのアプリケーションをチェックアウトしてください:
git clone git://github.com/Pylons/cluegun.git
virginia は非常に単純な動的 ファイル表示アプリケーションです。ファイルシステム上のディレクトリから、 構造化テキストドキュメント、HTML ドキュメント、画像を表示しようとします。 これは traversal のよい例でもあります。このアプリケーションの 初期のバージョンは repoze.org ウェブサイトを動かしていました。次のように してこのアプリケーションをチェックアウトしてください:
git clone git://github.com/Pylons/virginia.git
shootout は、 Carlos de la
Guardia と Lukasz Fidosz による「アイデア競争」アプリケーションの例です。
URL dispatch 、簡易認証、 SQLAlchemy
と pyramid_simpleform
の統合を実証します。次のようにしてこの
アプリケーションをバージョン管理からチェックアウトしてください:
git clone git://github.com/Pylons/shootout.git
KARL は Pyramid の上に構築された 中程度のサイズ (およそ 80K 行の Python コード) のアプリケーションです。 それは、共同作業、組織的なイントラネット、ナレッジマネジメント用の オープンソース・ウェブシステムで、 Wiki 、カレンダー、マニュアル、検索、 タグ付け、コメント、ファイルアップロード機能を提供します。 ダウンロードとインストールの詳細については、 KARL サイト を参照してください。
サポートと開発¶
Pylons Project ウェブサイト は、 Pyramid のサポートおよび開発情報についてのオンラインの主な情報源です。
バグを報告するためには、 issue tracker を使用してください。
このドキュメントが答えていない質問がある場合は、 Pylons-discuss メーリン グリスト に連絡するか、 #pyramid IRCチャンネル に join してください。
Pyramid GitHub リポジトリ 経由で
Pyramid のタグや trunk バージョンを閲覧、チェックアウトしてください。
git
を使って trunk をチェックアウトするためには、このコマンドを使用してください:
git clone git@github.com:Pylons/pyramid.git
Pyramid の貢献者になる方法を理解するためには、 ドキュメントの貢献者の セクション を 参照してください。