はじめよう

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(中垣健志)

はじめよう

web2pyにはWindowsとMac OS X用のバイナリパッケージが提供されています。また、Windows、Mac、Linux、その他のUnixシステムで動作するソースコードもあります。WindowsとOS Xのバイナリ版には、動作させるのに必要なPythonインタプリタが含まれます。ソースコードパッケージは、Pythonがすでにコンピュータにインストールされていることを前提としています。

web2py comes in binary packages for Windows and Mac OS X. There is also a source code version that runs on Windows, Mac, Linux, and other Unix systems. The Windows and OS X binary versions include the necessary Python interpreter. The source code package assumes that Python is already installed on the computer.

web2pyはインストールする必要がありません。始めるには、利用するオペーティングシステム用にダウンロードしたzipファイルを解凍して、適切なweb2pyファイルを実行します。

web2py requires no installation. To get started, unzip the downloaded zip file for your specific operating system and execute the corresponding web2py file.

Windowsの場合は、次のファイルを実行します:

On Windows, run:

1.

web2py.exe

OS Xの場合は、次のファイルを実行します:

On OS X, run:

1.

open web2py.app

UnixおよびLinuxでは、以下のコマンドを入力してソースから実行します:

On Unix and Linux, run from source by typing:

1.

python2.5 web2py.py

web2pyプログラムはさまざまなコマンドラインオプションを受け入れます。これは後ほど説明します。

The web2py program accepts various command line options which are discussed later.

デフォルトでは、起動時に、起動ウィンドウが表示されます:

By default, at startup, web2py displays a startup window:

その後、画面にはGUIウィジェットが表示され、一度限りの管理パスワード、Webサーバーに利用されるネットワークインターフェイスのIPアドレス、リクエストを受けるポート番号を選択するように求められます。デフォルトでは、web2pyは127.0.0.1:8000(ローカルホストのポート8000番)上で動作しますが、任意の取りうるIPアドレスとポートでも動作させることができます。ネットワークインターフェイスのIPアドレスは、コマンドラインを開いたあと、Windowsの場合はipconfigコマンドを、OS XやLinuxの場合はifconfigコマンドを入力する事で確認する事ができます。これ以降、web2pyはローカルホスト(127.0.0.1:8000)上で実行しているものとします。任意のネットワークインターフェイス上にweb2pyを公開して動作させるときは、0.0.0.0:80を使用してください。

and then displays a GUI widget that asks you to choose a one-time administrator password, the IP address of the network interface to be used for the web server, and a port number from which to serve requests. By default, web2py runs its web server on 127.0.0.1:8000 (port 8000 on localhost), but you can run it on any available IP address and port. You can query the IP address of your network interface by opening a command line and typing ipconfig on Windows or ifconfig on OS X and Linux. From now on we assume web2py is running on localhost (127.0.0.1:8000). Use 0.0.0.0:80 to run web2py publicly on any of your network interfaces.

管理者のパスワードを指定しない場合は、管理インターフェイスは無効になります。これは管理インターフェイスが公開されてしまう事を防ぐ、セキュリティ上の対策です。

If you do not provide an administrator password, the administration interface is disabled. This is a security measure to prevent publicly exposing the admin interface.

管理者インターフェイスadmin は、web2pyをApacheとmod_proxyを組み合わせた環境で実行させない限り、ローカルホストからしかアクセスできません。もし管理インターフェイスがプロキシを検出した場合は、セッションクッキーは保護されることとなり、管理インターフェイスのログインは、クライアントとプロキシがHTTPS上で通信しない限り、機能しません。これはセキュリティ対策のためです。クライアントと管理者間のすべての通信は、常にローカルまたは暗号化されている必要があります。そうしないと、攻撃者は中間者攻撃やリプレイ攻撃を行うことができ、サーバ上で任意のコードを実行することが可能になるからです。

The administrative interface, admin, is only accessible from localhost unless you run web2py behind Apache with mod_proxy. If admin detects a proxy, the session cookie is set to secure and admin login does not work unless the communication between the client and the proxy goes over HTTPS; this is a security measure. All communications between the client andadmin must always be local or encrypted; otherwise an attacker would be able to perform a man-in-the middle attack or a replay attack and execute arbitrary code on the server.

管理者用のパスワードが設定されたら、web2pyは次のページからWebブラウザを立ち上げます:

After the administration password has been set, web2py starts up the web browser at the page:

http://127.0.0.1:8000/

デフォルトのブラウザがない場合、Webブラウザを開いて、URLを入力してください。

If the computer does not have a default browser, open a web browser and enter the URL.

"administrative interface"をクリックすると、管理インターフェイス用のログインページが表示されます。

Clicking on "administrative interface" takes you to the login page for the administration interface.

管理者パスワードは、起動時に指定したパスワードと同じです。なお、管理者は1人だけで、したがって、1つの管理パスワードしかありません。セキュリティ上の理由により、web2pyが起動するたびに開発者は毎回新しいパスワードを尋ねられます。ただし、<recycle>オプションを指定するとその限りではありません。これは、web2pyの認証機構とは区別されます。

The administrator password is the password you chose at startup. Notice that there is only one administrator, and therefore only one administrator password. For security reasons, the developer is asked to choose a new password every time web2py starts unless the <recycle> option is specified. This is distinct from the authentication mechanism in web2py applications.

管理者がweb2pyにログインすると、ブラウザは"site"ページへとリダイレクトされます。

After the administrator logs into web2py, the browser is redirected to the "site" page.

このページではすべてのインストールされているweb2pyアプリケーションが列挙され、管理者はそれらを管理することができます。web2pyには次の3つのアプリケーションが付属しています:

This page lists all installed web2py applications and allows the administrator to manage them. web2py comes with three applications:

  • admin アプリケーション。これは現在あなたが利用しているものです。

    • An admin application, the one you are using right now.

  • examplesアプリケーション。これはオンラインの対話的なドキュメントと、web2pyの公式サイトのレプリカを持っています。

    • An examples application, with the online interactive documentation and a replica of the web2py official website.

  • welcomeアプリケーション。これは、他のweb2pyアプリケーションのための基本的なテンプレートです。これは、雛形となるアプリケーションとして参照されます。これは、起動時にユーザを迎えるアプリケーションです。

    • A welcome application. This is the basic template for any other web2py application. It is referred to as the scaffolding application. This is also the application that welcomes a user at startup.

すぐに利用できるweb2pyアプリケーションは、web2pyのアプライアンスとして参照されます。多くのフリーで利用可能なアプライアンスは34からダウンロードすることができます。 web2pyのユーザは、オープンソースかクローズドソース(コンパイルされてパックされたもの)のいずれの形式でも、新しいアプライアンスを投稿することが勧められています。

Ready-to-use web2py applications are referred to as web2py appliances. You can download many freely available appliances from 34 . web2py users are encouraged to submit new appliances, either in open-source or closed-source (compiled and packed) form.

admin アプリケーションのsiteページから、次の操作を行うことができます:

From the admin application's site page, you can perform the following operations:

  • install アプリケーションのインストールは、ページの右下にあるフォームを埋めて行います。アプリケーションの名前を入力し、パッケージ化されたアプリケーションを含むファイルを選択、または、アプリケーションが用意されているURLを指定して、"submit"ボタンをクリックします。

    • an application by completing the form on the bottom right of the page. Give a name to the application, select the file containing a packaged application or the URL where the application is located, and click "submit".

  • uninstall アプリケーションのアンインストールは対応するボタンをクリックして行います。確認ページが用意されています。

    • an application by clicking the corresponding button. There is a confirmation page.

  • create 新しいアプリケーションの作成は、名前を選択して"submit"ボタンをクリックして行います。

    • a new application by choosing a name and clicking "create".

  • package 配布用のアプリケーションのパッケージングは、対応するボタンをクリックして行います。ダウンロードされたアプリケーションは、データベースを含むすべてを保持するtarファイルです。このファイルのuntarはしてはいけません。adminでインストールしたときにweb2pyによって自動的にアンパッケージングされます。

    • an application for distribution by clicking on the corresponding button. A downloaded application is a tar file containing everything, including the database. You should not untar this file; it is automatically unpackaged by web2py when installed withadmin.

  • clean up セッションや、エラー、キャッシュファイルなどのアプリケーションの一時ファイルをクリーンアップします。

    • an application's temporary files, such as sessions, errors and cache files.

  • EDIT アプリケーションを編集します。

    • an application.

adminを用いて新規のアプリケーションを作成するときは、"welcome"雛形アプリのクローンから始まります。その中の"models/db.py"は、SQLiteデータベースを作成、接続し、Auth、Crud、Serviceをインスタンス化し、設定します。そこにはまた、"controller/default.py"があり、"index"、"download"、ユーザー管理のための"user"、サービスのための"call"というアクションを提供しています。ここから先、これらのファイルが削除されていることを前提としています。つまり、アプリをスクラッチから作成していきます。

When you create a new application using admin, it starts as a clone of the "welcome" scaffolding app with a "models/db.py" that creates a SQLite database, connects to it, instantiates Auth, Crud and Service, configures them. It also provides a "controller/default.py" which exposes actions "index", "download", "user" for user management, and "call" for services. In the following, we assume that these files have been removed; we will be creating apps from scratch.