原則

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(Omi Chiba)

原則

Pythonのプログラミングは、主として、以下の基本原則に従います:

Python programming typically follows these basic principles:

    • 同じことを繰り返さない (DRY)

    • Don't repeat yourself (DRY).

    • あることを実現する方法は一通りだけである

    • There should be only one way of doing things

    • 暗黙的よりも明示的を良しとする

    • Explicit is better than implicit.

web2pyは、最初の2つの原則は十分に取り入れています。コードの重複を抑制するようなソフトウェアエンジニアリングの健全なプラクティスの使用を促しています。また、Webアプリケーションの開発に共通するほぼすべてのタスク(フォームの作成や操作、セッション管理、クッキー、エラーなど)について指針を示します。

web2py fully embraces the first two principles by forcing the developer to use sound software engineering practices that discourage repetition of code. web2py guides the developer through almost all the tasks common in web application development (creating and processing forms, managing sessions, cookies, errors, etc.).

web2pyが他のフレームワークと異なるのは、3つ目の原則に関してです。これは最初の2つの原則と時々競合する事があります。特に、web2pyはユーザーアプリケーションをインポートするのではなく、事前定義されたコンテキストの上でそれらを実行します。このコンテキストでは、Pythonのキーワードだけでなく、web2pyのキーワードも公開されています。

web2py differs from other frameworks with regard to the third principle, which sometimes conflicts with the other two. In particular, web2py does not import user applications, but executes them in a predefined context. This context exposes the Python keywords, as well as the web2py keywords.

これらの機能は魔法のように見えるかもしれませんが、そうではありません。簡単に言うと、実際には、いくつかのモジュールはすでにインポートされ、あなたはそれをする必要がありません。他のフレームワークの面倒な特性である、すべてのモデルやコントローラの先頭に同じモジュールをインポートすることを強いることを避けるようにしています。

To some this may appear as magic, but it should not. Simply, in practice, some modules are already imported without you doing so. web2py is trying to avoid the annoying characteristic of other frameworks that force the developer to import the same modules at the top of every model and controller.

web2pyは、独自のモジュールをインポートすることにより、時間を節約し、ミスを防ぎます。このことは、「おなじ事を繰り返さない」、「あることを実現する方法は一通りだけである」という精神に基づいています。

web2py, by importing its own modules, saves time and prevents mistakes, thus following the spirit of "don't repeat yourself" and "there should be only one way of doing things".

他のPythonモジュールやサードパーティ製のモジュールを使用したい場合は、他のPythonプログラムと同様に、それらのモジュールを明示的にインポートしなければなりません。

If the developer wishes to use other Python modules or third-party modules, those modules must be imported explicitly, as in any other Python program.