2007年11月アーカイブ

どうせ読むので引き続き和訳

Configuration
-------------
All configuration files use the XML format now. All configuration files are validated against XML schemas, which means incorrect configuration files often result in an error right away. Also, XInclude (with XPointer) is supported, as well as "parent" configuration files that allow to enforce common settings for all projects in your organization. Of course, you can use any encoding you like for the XML files, but the default is UTF-8.

設定
-------------
全ての設定ファイルは XML フォーマットを使用します。全ての設定ファイルは XML スキーマによってバリデートされます。これは、正しくない設定ファイルはしばしば直ちにエラーとなることを意味します。親("parent")設定ファイルによって全てのプロジェクトに共通の設定を実行することが可能であり、また、XInclude (XPointer) もサポートされます。もちろん、XML ファイルにはどんな文字エンコーディングでも使用することができます(デフォルトは UTF-8 です)。

All configuration settings can either be valid under all situations, or only in one or more specific environments and/or contexts. This allows for very fine-grained control over what's happening. For instance, you can enable debug mode for the 'production' environment, or enable certain filters only in the 'web' context.

全ての設定は、全ての状況下で有効にすることも、一つあるいはそれ以上の特定の環境またはコンテキストで有効にすることもできます。これによりとてもきめ細かい制御が可能になります。たとえば、'production'環境においてデバッグモードを有効にしたり、あるフィルターを'web'コンテキストのみで有効にすることができます。

'contexts.ini' is gone, and we re-introduced 'factories.xml'. New config files are 'output_types.xml', 'routing.xml' and 'translation.xml'. 'filters.xml' was split up into separate files for global- and action filters.

'context.ini'はなくなり、'factries.xml'を再び導入しました。新たな設定ファイルは、'output_types.xml'、'routing.xml'、そして'translation.xml'です。'filters.xml'は'global-filters.xml'と'action-filters.xml'に分割されました。

'autoload.xml' 'compile.xml' and 'config_handlers.xml' use the "global" Agavi configuration files as their parents so it's not necessary anymore to sync them after each upgrade of Agavi.

'autoload.xml'、'compile.xml'、そして'config_handlers.xml'は、"global" Agavi 設定ファイル(訳注:agaviインストールディレクトリ/config/defaults/ 以下の同名ファイル)を親として使用するため、Agavi がアップグレードするたびにこれらを同期させる必要はなくなりました。

Only 'output_types.xml', 'factories.xml' and 'settings.xml' are now required for the system to run.

'output_types.xml'、'factories.xml'、そして'settings.xml'のみがシステムの実行に必須です。

「ビューとレンダリング」セクションを和訳してみた。ほぼ直訳なのは勘弁。

この前のセクションまでは http://d.hatena.ne.jp/MugeSo/20071122/1195721363

Views and Rendering
-------------------
With the new concept of output types, Views may implement execute() methods specifically for an output type by containing an executeSomething() methods, with "something" being the name of the output type.

ビューとレンダリング
-------------------
出力タイプという新しい概念により、ビューに executeSomething() メソッドを含めることである出力タイプ(something)に特化した execute() の実装が可能になりました。

Inside the views, a lot has changed. Templates and Decorator Templates are gone, and instead, there are now template layers. Each layer has a template, and each layer may have slots. The layers may even use different renderers!Layers are rendered in the order they are defined, with the output of a rendered layer being available to the next layer's template as $inner (what used to be $template['content']).

ビューの内部には多くの変更があります。テンプレートとデコレーターテンプレートはなくなり、その代わりにテンプレートレイヤーがあります。それぞれのレイヤーはテンプレート、時としてスロットを持ちます。レイヤーは異なるレンダラーを用いることすらできます!レイヤーは定義された順番にレンダリングされます。すでにレンダリングされたレイヤーの出力は、次にレンダリングされるレイヤーのテンプレート内で、$inner(かつての $template['content'])として使用することができます。

For added convenience, the layers can be grouped together into layouts that are defined for each output type in output_types.xml. A simple call to loadLayout() in a view will load these layers and their slots.

さらなる利便性のために、レイヤーは、出力タイプ毎に output_types.xhml で定義されたとおりにレイアウトにグループ化することができます。ビューの中で loadLayout() を呼び出すだけで、これらのレイヤーとスロットがロードされます。

Each of the slots can be given additional request arguments to work with, as well as an output type different from the current container's. To create an execution container for a slot, createSlotContainer can be used for more convenience. But remember that in most cases, it's better to define the slots in the layout configuration.

それぞれのスロットには、現在のコンテナとは異なる出力タイプだけでなく、追加のリクエスト引数も渡すことができます。スロット用の実行コンテナを作成するために createSlotContainer() を使用することができます。しかしほとんどのケースではレイアウト設定でスロットを定義する方が良いでしょう。

The entire new layered rendering system is very flexible and allows runtime changes to already loaded layouts etc. For instance, you could inject an intermediate layer between two registered layers in one of your views, or you could retrieve a slot that has been loaded for you by loadLayout and then change it's output type or set additional request arguments.

完全に新しくなったレイヤー化されたレンダリングシステムはとてもフレキシブルで、実行時にすでにロードされたレイアウトを変更することさえ可能です。たとえば、登録された2つのレイヤーの間に中間レイヤーを差し込んだり、loadLayout でロードされたスロットを取り出してその出力タイプを変更したり、追加のリクエスト引数をセットすることができます。

Also, each layer is represented by a class, usually AgaviFileTemplateLayer, but there is a generic AgaviStreamTemplateLayer class that allows you to fetch templates from databases, via HTTP, through SSH tunnels or even from inline strings using data:// streams!And implementing a custom layer that reads templates from a database, without writing a PHP stream wrapper, is possible, too, and very easy to do!

それぞれのレイヤーは一つのクラスにより表されます。それは通常 AgaviFileTemplateLayer ですが、より包括的な AgaviStreamTemplateLayer クラスもあります。AgaviStreamTemplateLayer クラスを使えば、テンプレートをデータベースや HTTP、SSH トンネリング通信、data:// ストリームを使えばインライン文字列からさえ取得することができます。データベースからテンプレートを読み込むカスタムレイヤーの実装のために PHP ストリームラッパーを書く必要はありません。とても簡単です!

It's a tad more complicated than the old system, and it needs getting used to, but it is all you ever wanted ;) Check out the documentation for it to learn more and see additional examples of what it's capable of.

このシステムは旧来のシステムよりも少し複雑で、慣れを必要としますが、これが本当に必要とされていたものなのです ;) さらに詳しく知るにはドキュメントを読んでください。

Also, you don't specify the template extension anymore when setting template names. The extension automatically appended by the system will be the default one for the specific renderer (.php, .tpl etc) unless you explicitly specify an extension you want to use instead. One of the reasons why this is done is that if you have i18n enabled, Agavi will automatically look for localized versions of your templates.

また、テンプレート名をセットする際に拡張子を指定する必要はなくなりました。明示的に拡張子を指定していない場合は、レンダラーに応じたデフォルトの拡張子(.php .tpl など)がシステムによって自動的に付加されます。これは、国際化対応(i18n)を有効にしている場合に、システムが自動的にロケールに応じたテンプレートを探せるようにするためです。

For templates, it is now possible to have Agavi's objects (Response, Request, Controller and so on) auto-assigned to variables. Also, the name of the variable that contains the template attributes can be configured to be different from 'template', just like the variable that stores the output of slots (which now defaults to 'slots'). Optionally, the template variable array can be extracted, so the attributes become available as variables by their names.

テンプレートは自動的に変数に assign された Agavi のオブジェクト(Response, Request, Controller など)を持つことが可能になりました。また、テンプレート attribute を含む変数の名前は、従来の'template'から変更することができます。たとえば、スロットの出力が格納されている変数はデフォルトで'slot'です。

The current response instance is available by calling getResponse() on the current view. This way, you could insert content into the response and then not set a template to skip rendering and return content in a different form. Typical situations would be when you set PHP data into the response which gets encoded to XMLRPC, or where you encode PHP data to JSON that is then set in the response.

現在のレスポンスインスタンスを getRensponse() で取得することができます。この方法により、レスポンスに直接コンテンツを挿入することができます。すなわち、テンプレートをセットせずにレンダリングをスキップして、異なる形式でコンテンツを返すことができます。その典型的なシチューションは、XMLRPC にエンコードされるレスポンスに PHP データをセットしたり、JSON 形式にエンコードした PHP データをレスポンスにセットしたりする場合です。

Also, you can set a stream on a response, that stream will then be output using fpassthru() for better performance. This is perfect for serving binary content. Simply do $this->getResponse()->setContent(fopen('/path/to/image.png', 'rb')); or something equivalent to make this happen. Keep in mind that you should do this in a dedicated output type for this response type, which obviously also needs the respective headers (like Content-Type: image/png in this case).

レスポンスにはストリームをセットすることも可能です(このストリームはよりよいパフォーマンスのために fpassthru() によって出力されます)。これはバイナリコンテンツを出力するためにパーフェクトな方法です。$this->getResponse()->setContent(fopen('/path/to/image.png', 'rb')); またはこれと等価の何かを実行するだけです。ただし、このレスポンスタイプには専用の出力タイプを用いるべきであることに注意してください。このレスポンスタイプはそれぞれ個別のヘッダ(この例の場合は、Content-type: image/png)を必要とするためです。

仕事では agavi-0.10 にお世話になりまくってますが、長い目で見ればやはりより洗練された設計であろう agavi-0.11 に乗り換えたいということで調査中。

0.10 はドキュメントが充実していないので導入コストがお高めな点もどうかと思うし。とはいえ 0.11 のドキュメントもまだ整備<予定>であり整備される保証はどこにもないですが。Symfony は本が出てたりしてうらやましい限り。

とりあえずは個人的なプロジェクトで使ってみる予定です。

URLと実行するアクションのマッピングが設定ファイルで可能になった(Routingのことね)

これでようやく、モジュール名、アクション名はできるだけ具体的でわかりやすいものにしたいけどURLは簡単なものにしたいというトレードオフから逃れられます。URLがフレームワーク丸出しなのもなんとなく気になってたし(携帯だとあまり気になりませんが)。

getModel() にインスタンス生成時の引数を渡せるようになった

メソッドの呼び出し順が限定されたりコンストラクタを別に作ったりと不格好なことをしなくてすむようになりました。

英語読むのに時間がかかってまだここまでしか不明。View にくくられていたところが View と Renderer に分かれたあたりもきっとうれしいんだと思う。

# それにしても agavi のシンボルであるあの地球外生命体みたいなものは何なんでしょう一体。

タイトルの通りなのですが、Pear の HTTP/Request, HTTP/Client が HTTPS でなおかつ Basic認証がかかっていると、環境によってはデータを取得できずに Malformed response なるエラーメッセージが発生したり(HTTP/Request)、レスポンスが空だったり(HTTP/Client)する問題に遭遇。

関連の Pear ライブラリのバージョンは正常動作の環境と同じだったので何かしらと思えば、extension の openssl が入っていなかったせいでした。

入れたら一瞬でおk。

経験値

| | コメント(0) | トラックバック(0)

経験値というのは偉大なもので、かつては見えなかったものも見えるようになっちゃうわけだ。するとその瞬間はやっぱおれってすげーみたいな誇らしい気分になるのだけど、逆に言うと結局自分は経験がなくてはその程度のものも見えないという程度の才能しか持ち合わせていないのであるなとちょっとがっかりする面もあったりするのである。

人が自分の能力に限界を見つけていく過程にあるものは、かならずしも挫折ばかりではないのかもしれない。

西の天才ピアニストことリヒテル様は、モスクワ音楽院の教授をして教えることが何もなかったといわしめたとかなんとか。(近現代の)クラッシック音楽界の偉人伝的になものに触れると、天才は生まれたときから天才、みたいなケースが多くてかなり切ない。特に指揮者。

どうやら getopt の引数を渡す ConsoleController::dispatch よりも前に、getopt を実行する ConsoleRequest::initialize (loadParameter)が呼ばれているせいで、 getopt が空振りしている模様。0.9 系からの version up 時に発生した問題かと思われます。

しかもご丁寧に、getopt は2回呼ぶと値が正常に取得できないというバグ(仕様?)付き。

あー時間損した。もう 0.10 系は過去のものになりそうなので、修正する気も当然起きず。

D200 を買おうかどうか検討していたら、もう D300 が発売ときたものです。

http://plusd.itmedia.co.jp/lifestyle/articles/0710/31/news091.html

写真を撮るという目的のための手段としてみれば、愛機 D100 は十分な道具であると思っているし、画素数(1200万は明らかに過剰)だとかソフトウェア的な部分の進歩(自動認識/補正系の機能イラネ)だとかにはあまり興味はないのだけど、視野率100%のファインダーが羨ましすぎる。D100 と D200 の超えられない質感の壁(特にシャッターの押し心地)も物欲を刺激して止まない。

そうは言っても D100 もせいぜい1万枚に届くかどうかという程度なので、シャッターユニットの寿命が10万ショットくらいはあるとするとまだまだ現役で使ってあげないとかわいそうな気もする。

写真の腕を上達させるには、コストを気にせず取りまくることができるデジタルと、一枚一枚大切に撮る気持ちを持つことができるフィルムのどちらが良いのかというのはなかなか難しい問題なのだけど、自分が旅行で写真に撮りたいのはただの風景ではなくて、そこに人がいる風景(かなり遠慮しながらなのでそんなのばかり撮ってるわけではないですが)という、どちらかといえばシャッターチャンスが限られている対象なので、その点無駄打ちがいくらでも許されるデジタルは圧倒的にありがたい。

フィルムはフィルムで、あの、世界を凝縮して閉じ込めた感じがなかなかに官能的で良いのですが(ポジ限定)。

このアーカイブについて

このページには、2007年11月に書かれたブログ記事が新しい順に公開されています。

前のアーカイブは2007年10月です。

次のアーカイブは2007年12月です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。