Flaskのパターン Patterns for Flask¶
ある種の目玉機能およびやり取りは、ほとんどのwebアプリケーションで見つけられるほど十分に一般的です。例えば、多くのアプリケーションではリレーショナルデータベースとユーザー認証を使用します。それらはリクエストの最初にデータベース接続を開き、ログインされたユーザーの情報を取得します。リクエストの最後には、データベース接続が閉じられます。 Certain features and interactions are common enough that you will find them in most web applications. For example, many applications use a relational database and user authentication. They will open a database connection at the beginning of the request and get the information for the logged in user. At the end of the request, the database connection is closed.
このような種類のパターンは多少Flask自身のスコープからは外側かもしれませんが、Flaskでは容易にそれらを実装できます。共通パターンのいくらかは、以下のページに集められています。 These types of patterns may be a bit outside the scope of Flask itself, but Flask makes it easy to implement them. Some common patterns are collected in the following pages.
- パッケージにした大きなアプリケーション(Large Applications as Packages)
- アプリケーション製造工場(Application Factories)
- アプリケーションの振り分け(Application Dispatching)
- Using URL Processors
- Setuptoolsを使った展開(Deploying with Setuptools)
- Deploying with Fabric
- FlaskでのSQLite 3の使用
- Flask内でのSQLAlchemy(SQLAlchemy in Flask)
- ファイルのアップロード
- キャッシング
- View Decorators
- WTFormsを使ったフォーム検証
- テンプレートの継承
- メッセージのフラッシュ表示(Message Flashing)
- AJAX with jQuery
- Lazily Loading Views
- MongoDB with MongoEngine
- Adding a favicon
- Streaming Contents
- Deferred Request Callbacks
- Adding HTTP Method Overrides
- Request Content Checksums
- Celery Background Tasks
- Flaskのサブクラス化
- Single-Page Applications