アプリケーション

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(中垣健志)

アプリケーション

web2pyで開発されたアプリケーションは、以下のパーツから構成されています:

Applications developed in web2py are composed of the following parts:

  • models は、データベースのテーブルとテーブル間のリレーションのようなデータの表現を記述します。

    • describe a representation of the data as database tables and relations between tables.

  • controllers は、アプリケーションのロジックとワークフローを記述します。

    • describe the application logic and workflow.

  • views は、JavaScriptとHTMLを使用してユーザにデータをどのように提示するかを記述します。

    • describe how data should be presented to the user using HTML and JavaScript.

  • languages は、アプリケーションの文字列を様々なサポートされている言語にどのように翻訳するかを記述します。

    • describe how to translate strings in the application into various supported languages.

  • static files は、処理を必要としません(たとえば画像やCSSスタイルシート等)。

    • do not require processing (e.g. images, CSS stylesheets, etc).

  • ABOUT and README は、その名のとおりの文書です。

    • documents are self-explanatory.

  • errors は、アプリケーションで発生したエラーのレポートを保存します。

    • store error reports generated by the application.

  • sessions は、各ユーザー固有の情報を保存します。

    • store information related to each particular user.

  • databases は、SQLiteデータベースと、付加的なテーブル情報を保存します。

    • store SQLite databases and additional table information.

  • cache は、キャッシュされたアプリケーションのアイテムを保存します。

    • store cached application items.

  • modules は、その他の追加Pythonモジュールです。

    • are other optional Python modules.

  • private ファイルは、コントローラからアクセスされますが、開発者から直接アクセスされません。

    • files are accessed by the controllers but not directly by the developer.

  • uploads ファイルは、モデルからアクセスされますが、開発者から直接アクセスされません(ユーザによりアップロードされたファイルなど)。

    • files are accessed by the models but not directly by the developer (e.g., files uploaded by users of the application).

  • tests は、テスト用のスクリプト、ちょっとしたプログラムやモックを格納するためのディレクトリです。

    • is a directory for storing test scripts, fixtures and mocks.

models、views、controllers、languages、static filesは、Webの管理[デザイン]インターフェイスを介してアクセス可能です。ABOUT、README、errorsも、管理インターフェイスを介して対応するメニュー項目を経てアクセスできます。sessions、cache、modules、private filesは、アプリケーションからはアクセスできますが、管理インターフェイスからはできません。

Models, views, controllers, languages, and static files are accessible via the web administration [design] interface. ABOUT, README, and errors are also accessible via the administration interface through the corresponding menu items. Sessions, cache, modules and private files are accessible to the applications but not via the administration interface.

ユーザがファイルシステムに直接アクセスする必要はないですが、すべては明確なディレクトリ構造にきれいに構造化されています。そして、インストールした各web2pyのアプリケーションに対して複製されます。

Everything is neatly organized in a clear directory structure that is replicated for every installed web2py application, although the user never needs to access the filesystem directly:

1.

2.

3.

__init__.py ABOUT LICENSE models views

controllers modules private tests cron

cache errors upload sessions static

"__init__.py"は、空のファイルで、Pythonがmodulesディレクトリ内のモジュールをインポートするために必要となります。

"__init__.py" is an empty file which is required in order to allow Python (and web2py) to import the modules in the modules directory.

なお、adminアプリケーションは、サーバのファイルシステムに置かれたweb2pyアプリケーションのためのWebインターフェイスを簡単に提供します。web2pyアプリケーションは、コマンドラインから作成、開発を行うこともできます。必ずしも、ブラウザのadminインターフェイスを使用しなければならないというわけではありません。新規のアプリケーションは、上記のディレクトリ構造を、たとえば、"applications/newapp/"の下に複製して手動で作ることができます(または新規アプリケーションのディレクトリにおいてwelcome.w2pを単純にuntarで展開しても可能です)。アプリケーションのファイルは、adminインターフェイスを使わずに、コマンドラインから作成や編集を行うことも可能です。

Notice that the admin application simply provides a web interface to web2py applications on the server file system. web2py applications can also be created and developed from the command-line; you don't have to use the browser admin interface. A new application can be created manually by replicating the above directory structure under ,e.g., "applications/newapp/" (or simply untar the welcome.w2p file into your new application directory). Application files can also be created and edited from the command-line without having to use the web admin interface.