GenshiのTutorial2(Getting Started)

見にくいので、後でWiki等にまとめたいと思います。Googleのsitesを進められたけど、折角だから自サバでTracでもと思っていたり。。。

Getting Started(はじめに)

Prerequisites(前提条件)

First, make sure you have CherryPy 3.0.x installed, as well as recent versions of FormEncode and obviously Genshi.
最初に、CherryPy 3.0.xと最近のFormEncodeとGenshiがインストールされていることを確認してください。

You can download and install those manually, or just use easy_install:
easy_installを使うことで、ダウンロードとインストールできます。

$ easy_install CherryPy
$ easy_install FormEncode
$ easy_install Genshi
The CherryPy Application(CherryPyアプリケーション)

Next, set up the basic CherryPy application.
次に、基本的なCherryPyアプリケーションをセットアップします。

  • 1. Create a directory that should contain the application

アプリケーションを含むディレクトリを作ってください。

  • 2. Inside that directory create a Python package named geddit by doing the following:

そのディレクトリ内にgeeditという名前のPythonパッケージを次のように作ってください。

    • Create a geddit directory

gedditディレクトリを作る

    • Create an empty file called __init__.py inside the geddit directory

gedditディレクトリ内に空の__init__.pyを作ってください。

  • 3. Inside the geddit package directory, create a file called controller.py with the following content:

gedditパッケージディレクトリ内に次のようにcontroller.pyを作ってください。

#!/usr/bin/env python

import operator, os, pickle, sys

import cherrypy


class Root(object):

    def __init__(self, data):
        self.data = data

    @cherrypy.expose
    def index(self):
        return 'Geddit'


def main(filename):
    data = {} # We'll replace this later

    # Some global configuration; note that this could be moved into a
    # configuration file
    cherrypy.config.update({
        'tools.encode.on': True, 'tools.encode.encoding': 'utf-8',
        'tools.decode.on': True,
        'tools.trailing_slash.on': True,
        'tools.staticdir.root': os.path.abspath(os.path.dirname(__file__)),
    })

    cherrypy.quickstart(Root(data), '/', {
        '/media': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': 'static'
        }
    })

if __name__ == '__main__':
    main(sys.argv[1])

Enter the tutorial directory in the terminal, and run:
チュートリアルディレクトリをターミナルに入力して、実行します。

$ PYTHONPATH=. python geddit/controller.py geddit.db

Note: On some Windows systems you may have to enter two lines:
Windowsの場合は、2行入力する必要があるかもしれません。

SET PYTHONPATH=.
python geddit/controller.py geddit.db

You should see a log message pointing you to the URL where the application is being served, which is usually http://localhost:8080/.

アプリケーションを扱うURLのログメッセージを確認します。通常 http://localhost:8080/ です。

Visiting that page will respond with just the string “Geddit”, as that's what the index() method of the Root object returns.
そのページにアクセスすると単なる文字列"Geddit”を返答します。それはインデックスメソッドの戻り値のルートオブジェクトです。

Note that we've configured CherryPy to serve static files from the geddit/static directory.
※geddit /静的なディレクトリから静的なファイルを扱えるようにCherryPyを設定します。

CherryPy will complain that that directory does not exist, so create it, but leave it empty for now. We'll add static resources later on in the tutorial.
CherryPyはそのディレクトリーが存在しないとエラーを出すので、作成してください。でも今は空のままにしておいてください。後でチュートリアルで、リソースを追加します。

JQueryのSpreadSheetあった!!

Dojoでやろうと思ってたけど、JQueryでもあるじゃん♪♪Tracのお勉強がてらにどうせならJQueryでやってみよう。

http://code.google.com/p/jqueryspreadsheet/
http://os.arandomurl.com/jqueryspreadsheet/

http://plugins.jquery.com/project/Sheet

googlecodeのがいい感じ♪♪

道のりは長いですが、楽しんでやっていきたいと思います。