init アプリケーション

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(中垣健志)

init アプリケーション

web2pyをデプロイするとき、デフォルトアプリケーションを設定したい場合があります。すなわち、次のようにURLのパスが空のときに起動するアプリケーションのことです:

When you deploy web2py, you will want to set a default application, i.e., the application that starts when there is an empty path in the URL, as in:

http://127.0.0.1:8000

デフォルトでは、空のパスに出くわしたら、web2pyはinitという名のアプリケーションを参照します。もし、initというアプリケーションがなかったら、welcomeという名のアプリケーションを参照します。

By default, when confronted with an empty path, web2py looks for an application called init. If there is no init application it looks for an application called welcome.

デフォルトのアプリケーションの名前は、routes.pyのdefault_applicationを設定することで、initから別の名前に変更することができます。

The name of the default application can be changed from init to another name by settingdefault_application in routes.py:

1.

default_application = "myapp"

注: default_applicationはweb2pyのバージョン1.83において最初に登場しました。

Note: default_application first appeared in web2py version 1.83.

ここでは、デフォルトアプリケーションを設定する方法は4通り(訳注:原文では3通りと記載)あります:

Here are three ways to set the default application:

  • あなたのデフォルトアプリケーションをinitと名付けます。

    • Call your default application "init".

  • routes.pyにおいてdefault_applicationをあなたのアプリケーションの名前に設定します。

    • Set default_application to your application's name in routes.py

  • "applications/init"から、あなたのアプリケーションのフォルダへのシンボリックリンクを作成します。

    • Make a symbolic link from "applications/init" to your application's folder.

  • 次節で説明するURLリライトを使用してください

    • Use URL rewrite as discussed in the next section.