blog20100901

2013/08/20 - プログラミング言語 Perl にまつわる etc. - Perl monger
参考 : perldoc, perldoc.jp, search.cpan.org, perldoc.perl.org ...
「 初めての Perl 第 6 版 」(オライリー・ジャパン発行 ISBN978-4-87311-567-2) 」
「 続・初めての Perl 改訂版 」(オライリー・ジャパン発行 ISBN4-87311-305-9) 」
「 Effective Perl 第 2 版 」(翔泳社発行 ISBN978-4-7981-3981-4) 」 ... etc,.

Perl Perl_7 mod_perl 翻訳 Web Server

Perl mp2 翻訳 1.0 から 2.0 への移行のためのリファレンス (d193)

目次 - Perl Index


Theme



Perl について、復習を兼ねて断片的な情報を掲載して行く連載その d193 回。

今回は、「 mod_perl Home / The mod_perl Web Site / Documentation / mod_perl 2.0 Documentation / User's guide / Part IV: Porting / A Reference to mod_perl 1.0 to mod_perl 2.0 Migration 」を翻訳して確認します。

正確な内容は 原文 を確認してください。誤解や誤訳がある場合はご指摘ください。





説明 : Description


This chapter is a reference for porting code and configuration files from mod_perl 1.0 to mod_perl 2.0.

このチャプタは mod_perl 1.0 から mod_perl 2.0 に移植するコードと構成ファイルのためのリファレンスです。
To learn about the porting process you should first read about porting Perl modules (and may be about porting XS modules).

移植プロセスを学ぶためにあなたは最初に porting Perl modules について呼んだほうがよいです (それとおそらく posrting XS modules についても)。
As it will be explained in details later, loading Apache2::compat at the server startup, should make the code running properly under 1.0 work under mod_perl 2.0. If you want to port your code to mod_perl 2.0 or writing from scratch and not concerned about backwards compatibility, this document explains what has changed compared to mod_perl 1.0.

後で詳しく説明されているように, サーバスタートアップ時の Apache2::compat のローディングは, 1.0 のもとで正しく走っているコードを mod_perl 2.0 のもとで機能するようにします。もしあなたがあなたのコードを mod_perl 2.0 に移植するまたはスクラッチしたくて後方互換をきにしないなら, このドキュメントは mod_perl 1.0 と比較して何が変更されたかを説明します。
Several configuration directives were changed, renamed or removed. Several APIs have changed, renamed, removed, or moved to new packages. Certain functions while staying exactly the same as in mod_perl 1.0, now reside in different packages. Before using them you need to find out those packages and load them.

いくつかの構成ディレクティブは変更, リネームや削除されています。いくつかの API は変更, リネーム, 削除, または新しいパッケージに移動されています。mod_perl 1.0 とまったく同じままの特定のファンクションは, いまは異なるパッケージに存在します。これらを使う前にあなたはそのパッケージを見つけ出しこれらをロードする必要がります。
You should be able to find the destiny of the functions that you cannot find any more or which behave differently now under the package names the functions belong in mod_perl 1.0.

あなたはもうあなたが見つけることができないあるいは mod_perl 1.0 に属するパッケージ名のもとでのファンクションと動作が違うといったファンクションの運命を見つけられるようになるでしょう。


構成ファイルの移植 : Configuration Files Porting


To migrate the configuration files to the mod_perl 2.0 syntax, you may need to do certain adjustments. Several configuration directives are deprecated in 2.0, but still available for backwards compatibility with mod_perl 1.0 unless 2.0 was built with MP_COMPAT_1X=0. If you don't need the backwards compatibility consider using the directives that have replaced them.

構成ファイルを mod_perl 2.0 のシンタクスに移行するために, あなたはある程度の調整を必要とするはずです。いくつかの構成ディレクティブは 2.0 で廃止予定とされていますが, 2.0 が MP_COMPAT_1X=0 でビルドされていなければ mod_perl 1.0 との後方互換はまだ利用可能です。あなたが後方互換を必要でないならそれらを置き換えたディレクティブの仕様を考慮してください。


PerlHandler


PerlHandler was replaced with PerlResponseHandler.

PerlHandler は PerlResponseHandler で置換されました.


PerlScript


PerlScript was replaced with PerlRequire. PerlRequire is available in mod_perl 1.0, since 1997.

PerlScript は PerlRequire で置換されました。 PerlRequire は 1997 から mod_perl 1.0 で利用出来ます。


PerlSendHeader


PerlSendHeader was replaced with PerlOptions +/-ParseHeaders directive.

PerlSendHeader は PerlOptions +/-ParseHeaders ディレクティブで置換されました。

PerlSendHeader On => PerlOptions +ParseHeaders
PerlSendHeader Off => PerlOptions -ParseHeaders



PerlSetupEnv


PerlSetupEnv was replaced with PerlOptions +/-SetupEnv directive.

PerlSetupEnv は PerlOptions +/-SetupEnv ディレクティブで置換されました。

PerlSetupEnv On => PerlOptions +SetupEnv
PerlSetupEnv Off => PerlOptions -SetupEnv



PerlTaintCheck


The taint mode now can be turned on with PerlSwitches:

taint モードは現在 PerlSwitches で on にできます:

PerlSwitches -T

As with standard Perl, by default the taint mode is disabled and once enabled cannot be turned off inside the code.

標準の Perl と同様に, デフォルトで taint モードは無効化されていて 1 度有効化するとコード内では off にできません。


PerlWarn


Warnings now can be enabled globally with PerlSwitches:

警告は PerlSwitches でグローバルに有効化できるようになりました:

PerlSwitches -w



PerlFreshRestart


PerlFreshRestart is a mod_perl 1.0 legacy and doesn't exist in mod_perl 2.0. A full teardown and startup of interpreters is done on restart.

PerlFreshRestart は mod_perl 1.0 のレガシーで mod_perl 2.0 では存在しません。インタプリタの完全な解体とスタートアップはリスタート時に行われます。
If you need to use the same httpd.conf for 1.0 and 2.0, use:

もしあなたが 1.0 と 2.0 で同じ httpd.conf を使う必要があるなら, これを使います:

<IfDefine !MODPERL2>
PerlFreshRestart
</IfDefine>



$Apache::Server::StrictPerlSections


In mod_perl 2.0, <Perl> sections errors are now always fatal. Any error in them will cause an immediate server startup abort, dumping the error to STDERR. To avoid this, eval {} can be used to trap errors and ignore them. In mod_perl 1.0, strict was somewhat of a misnomer.

mod_perl 2.0 で, <Perl> sections のエラーは常に致命的です。そのエラーが発生するとただちにサーバスタートアップは中止され, STDERR にエラーがダンプされます。これを回避するには, エラーをトラップする eval {} を使いそれらを無視します。mod_perl 1.0 での, strict は少し誤った名前でした。


$Apache::Server::SaveConfig


$Apache::Server::SaveConfig has been renamed to $Apache2::PerlSections::Save. see <Perl> sections for more information on this global variable.

$Apache::Server::SaveConfig は $Apache2::PerlSections::Save にリネームされました。このグローバル変数の詳細は <Perl> sections を参照してください。


Apache 構成のカスタマイズ : Apache Configuration Customization


mod_perl 2.0 has slightly changed the mechanism for adding custom configuration directives and now also makes it easy to access an Apache parsed configuration tree's values.

META: add to the config tree access when it'll be written.

mod_perl 2.0 はカスタム構成ディレクティブの追加のメカニズムを少し変更していて Apache でパースされた構成ツリーの値へのアクセスが簡単にできるようになりましました。

META: それが書かれるときの構成ツリーアクセスを追加する。


@INC の操作 : @INC Manipulation



  • Directories Added Automatically to @INC

    @INC に自動的に追加されるディレクトリ
    Only if mod_perl was built with MP_COMPAT_1X=1, two directories: $ServerRoot and $ServerRoot/lib/perl are pushed onto @INC. $ServerRoot is as defined by the ServerRoot directive in httpd.conf.

    mod_perl が MP_COMPAT_1X=1 でビルドされた場合のみ, 2 つのディレクトリ: $ServerRoot と $ServerRoot/lib/perl が @INC 上にプッシュされます。$ServerRoot は httpd.conf の ServerRoot ディレクティブで定義されているとおりです。

  • PERL5LIB and PERLLIB Environment Variables

    PERL5LIB と PERLLIB 環境変数
    mod_perl 2.0 doesn't do anything special about PERL5LIB and PERLLIB Environment Variables. If -T is in effect these variables are ignored by Perl. There are several other ways to adjust @INC.

    mod_perl 2.0 は PERL5LIB と PERLLIB 環境変数について特別なことは何も行いません。もし -T 有効ならこれらの変数は Perl によって無視されます。@INC を調整する他の方法がいくつかあります。




サーバの起動 : Server Startup


mod_perl 1.0 was always running its startup code as soon as it was encountered. In mod_perl 2.0, it is not always the case. Refer to the mod_perl 2.0 startup process section for details.

mod_perl 1.0 はスタートアップコードがエンカウントすると常にすぐ走っていました。mod_perl 2.0 で, これは常にそうなるわけではありません。詳細は mod_perl 2.0 startup process section を参照してください。


コードの移植 : Code Porting


mod_perl 2.0 is trying hard to be back compatible with mod_perl 1.0. However some things (mostly APIs) have been changed. In order to gain a complete compatibilty with 1.0 while running under 2.0, you should load the compatibility module as early as possible:

mod_perl 2.0 は mod_perl 1.0 と後方互換できるようにハードにトライしています。しかしいくつかのもの (ほぼ API) は変更されています。
2.0 のもとで走っていながら 1.0 との完全な互換性を得るためには, あなたはできるだけ早く互換性モジュールをロードしたほうがよいでしょう:

use Apache2::compat;

at the server startup. And unless there are forgotten things or bugs, your code should work without any changes under 2.0 series.

これをサーバのスタートアップで。これで忘れているものやバグがない限りは, あなたのコードは変更なく 2.0 シリーズのもとで機能するはずです。
However, unless you want to keep the 1.0 compatibility, you should try to remove the compatibility layer and adjust your code to work under 2.0 without it. You want to do it mainly for the performance improvement.

しかし, あなたが 1.0 との互換性を維持したいわけではない場合, あなたは互換レイヤを削除してあなたのコードがそれなしでも 2.0 のもとで機能するように調整することを試みるとよいです。主にパフォーマンス向上のためにあなたはこれをやりたいはずです。
This document explains what APIs have changed and what new APIs should be used instead.

このドキュメントは何の API が変更され何の新しい API がかわりに使われるかを説明します。
Finally, mod_perl 2.0 has all its methods spread across many modules. In order to use these methods the modules containing them have to be loaded first. The module ModPerl::MethodLookup can be used to find out which modules need to be used. This module also provides a function preload_all_modules() that will load all mod_perl 2.0 modules, implementing their API in XS, which is useful when one starts to port their mod_perl 1.0 code, though preferrably avoided in the production environment if you want to save memory.

最後に, mod_perl 2.0 はそのすべてのメソッドを多くのモジュールにわたって分散してもっています。それらのメソッドを使うためにはそれらを含むモジュールを最初にロードしておく必要があります。モジュール ModPerl::MethodLookup はどのモジュールを使う必要があるかを見つけ出すために使われます。このモジュールはまたすべての mod_perl 2.0 モジュールをロードするファンクション preload_all_modules() を提供し, それらの API を XS で実装します, これは mod_perl 1.0 コードの移植をはじめるときに便利ですが, プロダクション環境であなたがメモリの節約をしたい場合はできるだけ避けたほうがよいでしょう。


Apache::Registry, Apache::PerlRun and Friends


Apache::Registry, Apache::PerlRun and other modules from the registry family now live in the ModPerl:: namespace. In mod_perl 2.0 we put mod_perl specific functionality into the ModPerl:: namespace, similar to APR:: and Apache2:: which are used for libapr and Apache, respectively.

Apache::Registry, Apache::PerlRun とレジストリファミリからの他のモジュールは現在 Mod::Perl:: 名前空間にいます。mod_perl 2.0 で私たちは libapr と Apache で、それぞれ使われる, APR:: と Apache2:: と同じように, mod_perl 固有のファンクションを ModPerl:: 名前空間に置きました。
ModPerl::Registry (and others) doesn't chdir() into the script's dir like Apache::Registry does, because chdir() affects the whole process under threads. If you need this functionality use ModPerl::RegistryPrefork or ModPerl::PerlRunPrefork.

ModPerl::Registry (とその他) は Apache::Registry がするようにはスクリプトの dir に chdir() しません, なぜなら chdir() はスレッド下のプロセス全体に影響するからです。あなたがこの機能を必要とするなら ModPerl::RegistryPrefork や ModPerl::PerlRunPrefork を使います。
Otherwise ModPerl::Registry modules are configured and used similarly to Apache::Registry modules. Refer to one of the following manpages for more information: ModPerl::RegistryCooker, ModPerl::Registry, ModPerl::RegistryBB and ModPerl::PerlRun.

そうでなければ ModPerl::Registry モジュールは Apache::Registry モジュールと同じように構成され使われます。詳細のために次の man ページのいずれかを参照してください: ModPerl::RegistryCooker, ModPerl::Registry, ModPerl::RegistyrBB それから ModPerl::PerlRun。


ModPerl::RegistryLoader


In mod_perl 1.0 it was only possible to preload scripts as Apache::Registry handlers. In 2.0 the loader can use any of the registry classes to preload into. The old API works as before, but new options can be passed. See the ModPerl::RegistryLoader manpage for more information.

mod_perl 1.0 では Apache::Registry ハンドラとしてスクリプトをプレロードすることだけができました。2.0 ではローダはプレロードするためにどのレジストリクラスでも使うことができるようになっています。古い API は以前のように機能しますが, 新しいオプションを渡すことができます。詳細は ModPerl::RegistryLoader man ページを参照してください。


Apache::Constants


Apache::Constants has been replaced by three classes:

Apache::Constants は 3 つのクラスにリプレイスされました:

  • Apache2::Const
    Apache constants

    Apache 定数

  • APR::Const
    Apache Portable Runtime constants

    Apache 移植ランタイム定数

  • ModPerl::Const
    mod_perl specific constants

    mod_perl 固有の定数


See the manpages of the respective modules to figure out which constants they provide.

これらが提供する定数を見つけ出すためにそれぞれのモジュールの man ページを参照してください。
META: add the info how to perform the transition. XXX: may be write a script, which can tell you how to port the constants to 2.0? Currently Apache2::compat doesn't provide a complete back compatibility layer.

META: そのように以降を実行するかの情報を追加する。 XXX: あなたにどのように定数を 2.0 に移植するかを伝える, スクリプトを書いたほうがいいかも ? 現在 Apache2::compat は完全な後方互換レイヤを提供していない。


定数の共存 : mod_perl 1.0 and 2.0 Constants Coexistence


If the same codebase is used for both mod_perl generations, the following technique can be used for using constants:

同じコードベースが両方の mod_perl ジェネレーションで使われている場合は, 定数を使うための次のテクニックが使えます:

package MyApache2::Foo;

use strict;
use warnings;

use mod_perl;
use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and
$ENV{MOD_PERL_API_VERSION} >= 2 );

BEGIN {
if (MP2) {
require Apache2::Const;
Apache2::Const->import(-compile => qw(OK DECLINED) );
}
else {
require Apache::Constants;
Apache::Constants->import(qw(OK DECLINED));
}
}

sub handler {
# ...
return MP2 ? Apache2::Const::OK : Apache::Constants::OK;
}
1;

Notice that if you don't use the idiom:

あなたがこのイディオムを使わないならこれに注目して下さい:

return MP2 ? Apache2::Const::OK : Apache::Constants::OK;

but something like the following:

しかし次のようなものでは:

sub handler1 {
...
retun Apache::Constants::OK();
}
sub handler2 {
...
retun Apache2::Const::OK();
}

You need to add (). If you don't do that, let's say that you run under mod_perl 2.0, perl will complain about mod_perl 1.0 constant:

あなたは () を追加する必要があります。あなたがこれをせずに, あなたが mod_perl 2.0 のもとで実行したとすると, perl は mod_perl 1.0 の定数について文句をいいます:

Bareword "Apache::Constants::OK" not allowed while "strict subs" ...

Adding () prevents this warning.

() を追加することでこの警告を防止できます。


廃止予定の定数 : Deprecated Constants


REDIRECT and similar constants have been deprecated in Apache for years, in favor of the HTTP_* names (they no longer exist Apache 2.0). mod_perl 2.0 API performs the following aliasing behind the scenes:

REDIRECT や同様の定数は Apache で HTTP_* 名前が指示されていて, 何年も廃止予定にてなっています (Apache 2.0 でこれらはもう存在しません)。 mod_perl 2.0 API は舞台裏で次のエイリアシングを実行します:

NOT_FOUND => 'HTTP_NOT_FOUND',
FORBIDDEN => 'HTTP_FORBIDDEN',
AUTH_REQUIRED => 'HTTP_UNAUTHORIZED',
SERVER_ERROR => 'HTTP_INTERNAL_SERVER_ERROR',
REDIRECT => 'HTTP_MOVED_TEMPORARITY',

but we suggest moving to use the HTTP_* names. For example if running in mod_perl 1.0 compatibility mode, change:

しかし私たちは HTTP_* の名前の使用に移行することをお勧めします。例えば mod_perl 1.0 互換モードで実行しているなら, このように変更します:

use Apache::Constants qw(REDIRECT);

to:

use Apache::Constants qw(HTTP_MOVED_TEMPORARITY);

This will work in both mod_perl generations.

これは両方の mod_perl ジェネレーションで機能します。


SERVER_VERSION()


Apache::Constants::SERVER_VERSION() has been replaced with Apache2::ServerUtil::get_server_version().

Apache::Constants::SERVER_VERSION() は Apache2::ServerUtil::get_server_version() にリプレイスされました。


export()


Apache::Constants::export() has no replacement in 2.0 as it's not needed.

Apache::Constants::export() は 2.0 では (# サポートが) 必要とされいないためリプレイスされていません。


環境変数での問題 : Issues with Environment Variables


There are several thread-safety issues with setting environment variables.

環境変数の設定でスレッドセーフの問題がいくつかあります。
Environment variables set during request time won't be seen by C code. See the DBD::Oracle issue for possible workarounds.

リクエストタイムの間でセットした環境変数は C コードから見えません。考えられる回避策は DBD::Oracle の問題を参照してください。
Forked processes (including backticks) won't see CGI emulation environment variables. (META: This will hopefully be resolved in the future, it's documented in modperl_env.c:modperl_env_magic_set_all.)

フォークされたプロセス (バッククォート (# よるもの) を含む) は CGI エミュレーション環境変数が見えません。(META: これは将来解決されることを願います, これは modperl_env.c:modperl_env_magic_set_all でドキュメント化されています。)


特別な環境変数 : Special Environment Variables




$ENV{GATEWAY_INTERFACE}


The environment variable $ENV{GATEWAY_INTERFACE} is not special in mod_perl 2.0, but the same as any other CGI environment variables, i.e. it'll be enabled only if PerlOptions +SetupEnv is enabled and its value would be the default:

環境変数 $ENV{GATEWAY_INTERFACE} は mod_perl 2.0 では特別ではありませんが, 他の CGI 環境変数と同じです, i.e. PerlOptions +SetupEnv が有効でその値がデフォルトになる場合でのみ有効になります:

CGI/1.1

or anything else Apache decides to set it to, but not:

または他のものの設定は Apache が決めるが, これはしない:

CGI-Perl/1.1

Instead use $ENV{MOD_PERL} (available in both mod_perl generations), which is set to the mod_perl version, like so:

かわりに $ENV{MOD_PERL} を使う (両方の mod_perl ジェネレーションで利用出来る), これは mod_perl バージョンをセットします, このように:

mod_perl/2.000002

Therefore in order to check whether you are running under mod_perl, you'd say:

したがってあなたが mod_perl のもとで実行しているかどうかをチェックするために, あなたはいえます:

if ($ENV{MOD_PERL}) { ... }

To check for a specific version it's better to use $ENV{MOD_PERL_API_VERSION}

特定のバージョンを確認するためには $ENV{MOD_PERL_API_VERSION} の使用がベターです

use mod_perl;
use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and
$ENV{MOD_PERL_API_VERSION} >=2 );



Apache::Methods




Apache->request


Apache->request has been replaced with Apache2::RequestUtil::request().

Apache->request は Apache2::RequestUtil::request() でリプレイスされました。
Apache2::RequestUtil->request usage should be avoided under mod_perl 2.0 $r should be passed around as an argument instead (or in the worst case maintain your own global variable). Since your application may run under threaded mpm, the Apache2::RequestUtil->request usage involves storage and retrieval from the thread local storage, which is expensive.

Apache2::RequestUtil->request の使用は mod_perl 2.0 のもとでは避ける必要があり $r を引数として渡す必要があります (または最悪のケースでもあなた独自のグローバル変数は維持する)。あなたのアプリケーションがスレッド mpm のもとで走るかもしれないので, Apache2::RequestUtil->request の使用はスレッドローカルストレージからの取得と保管をともない, これは高価です。
It's possible to use $r even in CGI scripts running under Registry modules, without breaking the mod_cgi compatibility. Registry modules convert a script like:

mod_cgi の互換性を壊すことなく, Registry モジュールのもとで走る CGI スクリプトでも $r を使うことができます。このような Registry モジュールのスクリプトの変換は:

print "Content-type: text/plain";
print "Hello";

into something like:

このようなものに:

package Foo;
sub handler {
print "Content-type: text/plain\n\n";
print "Hello";
return Apache2::Const::OK;
}

where the handler() function always receives $r as an argument, so if you change your script to be:

handler() ファンクションは常に $r を引数として受けとりますので, もしあなたがあなたのスクリプトを変更するなら:

my $r;
$r = shift if $ENV{MOD_PERL};
if ($r) {
$r->content_type('text/plain');
}
else {
print "Content-type: text/plain\n\n";
}
print "Hello"

it'll really be converted into something like:

これは実際にはこのようなものに変換されます:

package Foo;
sub handler {
my $r;
$r = shift if $ENV{MOD_PERL};
if ($r) {
$r->content_type('text/plain');
}
else {
print "Content-type: text/plain\n\n";
}
print "Hello"
return Apache2::Const::OK;
}

The script works under both mod_perl and mod_cgi.

このスクリプトは mod_perl と mod_cgi の両方で機能します。
For example CGI.pm 2.93 or higher accepts $r as an argument to its new() function. So does CGI::Cookie::fetch from the same distribution.

例えば CGI.pm 2.93 以上はその new() ファンクションに引数として $r を受けいれます。同じディストリビューションの CGI::Cookie::fetch もそうです。
Moreover, user's configuration may preclude from Apache2::RequestUtil->request being available at run time. For any location that uses Apache2::RequestUtil->request and uses SetHandler modperl, the configuration should either explicitly enable this feature:

さらに, ユーザの構成がランタイムでの Apache2::RequestUtil->request をできなくするかもしれません。Apache2::RequestUtil->request を使い SetHandler modperl を使う場所では, 構成でこのどちらかの機能を明示的に有効化しなければなりません:

<Location ...>
SetHandler modperl
PerlOptions +GlobalRequest
...
</Location>

It's already enabled for SetHandler perl-script:

SetHandler perl-script ではすでに有効化されています:

<Location ...>
SetHandler perl-script
...
</Location>

This configuration makes Apache2::RequestUtil->request available only during the response phase (PerlResponseHandler). Other phases can make Apache2::RequestUtil->request available, by explicitly setting it in the handler that has an access to $r. For example the following skeleton for an authen phase handler makes the Apache2::RequestUtil->request available in the calls made from it:

この構成はレスポンスフェーズ (PerlResponseHandler) の間でのみ Apache2::RequestUtil->request を利用可能にします。他のフェーズでは $r にアクセスできるハンドラで明示的にセットすることで, Apache2::RequestUtil->request が利用可能になります。例えば authen パースハンドラのための次のスケルトンは Apache2::RequestUtil->request をそれからの呼びだしで利用可能にします:

package MyApache2::Auth;

# PerlAuthenHandler MyApache2::Auth

use Apache2::RequestUtil ();
#...
sub handler {
my $r = shift;
Apache2::RequestUtil->request($r);
# do some calls that rely on Apache2::RequestUtil->request being available
# Apache2::RequestUtil->request が利用可能であることに頼る何らかのコールを行う
#...
}



Apache->define


Apache->define has been replaced with Apache2::ServerUtil::exists_config_define().

Apache->define は Apache2::ServerUtil::exists_config_define() にリプレイスされました。


Apache->can_stack_handlers


Apache->can_stack_handlers is no longer needed, as mod_perl 2.0 can always stack handlers.

Apache->can_stack_handlers はもう不要になりました, mod_perl 2.0 は常にハンドラをスタックできます。


Apache->untaint


Apache->untaint has moved to Apache2::ModPerl::Util::untaint() and now is a function, rather a class method. It'll will untaint all its arguments. You shouldn't be using this function unless you know what you are doing. Refer to the perlsec manpage for more information.

Apache->untaint は Apache2::ModPerl::Util::untaint() に移動されていまはクラスメソッドではなく, ファンクションです。それはそのすべての引数を untaint します。あなたはあなたが何をしているか知っている場合以外ではこのファンクションを使わないでください。詳細は perlsec man ページを参照してください。
Apache2::compat provides the backward compatible with mod_perl 1.0 implementation.

Apache2::compat は mod_perl 1.0 実装との後方互換を提供します。


Apache->get_handlers


To get handlers for the server level, mod_perl 2.0 code should use Apache2::ServerUtil::get_handlers():

サーバレベルのハンドラを取得するために, mod_perl 2.0 コードは Apache2::ServerUtil::get_handlers() を使う必要があります:

$s->get_handlers(...);

or:

Apache2::ServerUtil->$s->get_handlers(...);

Apache->get_handlers is avalable via Apache2::compat.

Apache->get_handlers は Apache2::compat を介して利用可能です。

See also Apache2::RequestUtil::get_handlers().


Apache->push_handlers


To push handlers at the server level, mod_perl 2.0 code should use Apache2::ServerUtil::push_handlers():

サーバレベルのハンドラをプッシュするために, mod_perl 2.0 のコードは Apache2::ServerUtil::push_handlers() を使う必要があります:

$s->push_handlers(...);

or:

Apache2::ServerUtil->server->push_handlers(...);

Apache->push_handlers is avalable via Apache2::compat.

Apache->push_handlers は Apache2::compat を介して利用可能です。

See also Apache2::RequestUtil::push_handlers().


Apache->set_handlers


To set handlers at the server level, mod_perl 2.0 code should use Apache2::ServerUtil::set_handlers():

サーバレベルのハンドラをセットするために, mod_perl 2.0 コードは Apache2::ServerUtil::set_handlers() を使う必要があります。

$s->set_handlers(...);

or:

Apache2::set_handlers->server->set_handlers(...);

Apache->set_handlers is avalable via Apache2::compat.

Apache->set_handlers は Apache2::compat を介して利用可能です。
To reset the list of handlers, instead of doing:

ハンドラのリストをリセットするためには, これを行うかわりに:

$r->set_handlers(PerlAuthenHandler => [ \&OK ]);

do:

これを行います:

$r->set_handlers(PerlAuthenHandler => []);

or

$r->set_handlers(PerlAuthenHandler => undef);

See also Apache2::RequestUtil::set_handlers().


Apache->httpd_conf


Apache->httpd_conf is now $s->add_config:

Apache->httpd_conf はいまは $s->add_confid です:

require Apache2::SeverUtil;
Apache2::ServerUtil->server->add_config(['require valid-user']);

Apache->httpd_conf is avalable via Apache2::compat.

Apache->httpd_conf は Apache2::compat を介して利用可能です。

See also Apache2::RequestUtil::add_config()


Apache->unescape_uri_info


Apache->unescape_url_info is not available in mod_perl 2.0 API. Use CGI::Util::unescape instead (http://search.cpan.org/dist/CGI.pm/CGI/Util.pm).

Apache->unescape_url_info は mod_perl 2.0 API では利用できません。かわりに CGI::Util::unescape を使います (http://search.cpan.org/dist/CGI.pm/CGI/Util.pm)。
It is also available via Apache2::compat for backwards compatibility.

これも後方互換のために Apache2::compat を介して利用可能です。


Apache::exit()


Apache::exit() has been replaced with ModPerl::Util::exit().

Apache::exit() は ModPerl::Util::exit() でリプレイスされました。


Apache::gensym()


Since Perl 5.6.1 filehandlers are autovivified and there is no need for Apache::gensym() function, since now it can be done with:

Perl 5.6.1 のファイルハンドラは自動有効化 (autovivification: (d013)) されるので Apache::gensym() ファンクションの必要がなくなり, 今ではそれをこれでできます:

open my $fh, "foo" or die $!;

Though the C function modperl_perl_gensym() is available for XS/C extensions writers.

けれども C ファンクション modperl_perl_gensym() は XS/C 拡張の作者のために利用可能です。


Apache::log_error()


Apache::log_error() is not available in mod_perl 2.0 API. You can use Apache2::Log::log_error():

Apache::log_error() は mod_perl 2.0 API で利用できません。あなたは Apache2::Log::log_error() を使えます:

Apache2::ServerUtil->server->log_error

instead. See the Apache2::Log manpage.

かわりに。Apache2::Log man ページを参照してください。


Apache->warn


$Apache->warn has been removed and exists only in
Apache2::compat
. Choose another Apache2::Log method.

$Apache->warn は削除され Apache2::compat でのみ存在します。他の Apache2::Log メソッドを選んでください。


Apache::warn


$Apache::warn has been removed and exists only in Apache2::compat. Choose another Apache2::Log method.

$Apache::warn は削除され Apache2::compat でのみ存在します。他の Apache2::Log メソッドを選んでください。


Apache::module()


Apache::module()
has been replaced with the function Apache2::Module::loaded(), which now accepts a single argument: the module name.

Apache::module() はファンクション Apache2::Module::loaded() でリプレイスされ, 単一の引数: モジュール名を受け入れるようになりました。


Apache::Variables




$Apache::__T


$Apache::__T is deprecated in mod_perl 2.0. Use
${^TAINT}
instead.

$Apache::__T は mod_perl 2.0 で廃止予定です。かわりに ${^TAINT} を使います。


Apache::Module:: Methods




Apache::Module->top_module


Apache::Module->top_module has been replaced with the function Apache2::Module::top_module().

Apache::Module->top_module はファンクション Apache2::Module::top_module() でリプレイスされました。


Apache::Module->get_config


Apache::Module->get_config
has been replaced with the function Apache2::Module::get_config().

Apache::Module->get_config はファンクション Apache2::Module::get_config() でリプレイスされました。


Apache::ModuleConfig:: Methods





Apache::ModuleConfig->get


Apache::ModuleConfig->get has been replaced with the function
Apache2::Module::get_config()
.

Apache::ModuleConfig->get はファンクション Apache2::Module::get_config() でリプレイスされました。


Apache::Server:: Methods and Variables




$Apache::Server::CWD


$Apache::Server::CWD is deprecated and exists only in Apache2::compat.

$Apache::Server::CWD は廃止予定で Apache2::compat でのみ存在します。


$Apache::Server::AddPerlVersion


$Apache::Server::AddPerlVersion is deprecated and exists only in Apache2::compat.

$Apache::Server::AddPerlVersion は廃止予定で Apache2::compat でのみ存在します。


$Apache::Server::Starting and $Apache::Server::Restarting


$Apache::Server::Starting and $Apache::Server::ReStarting were replaced by Apache2::ServerUtil::restart_count(). Though both exist in Apache2::compat.

$Apache::Server::Starting と $Apache::Server::Restarting は Apache2::ServerUtil::restart_count() によりリプレイスされました。けれども Apache2::compat で両方存在します。


Apache::Server->warn


Apache::Server->warn has been removed and exists only in Apache2::compat. Choose another Apache2::Log method.

Apache::Server->warn は削除され Apache2::compat でのみ存在します。他の Apache2::Log メソッドを選んでください。


サーバオブジェクトメソッド : Server Object Methods




$s->register_cleanup


$s->register_cleanup has been replaced with APR::Pool::cleanup_register() which accepts the pool object as the first argument instead of the server object, a callback function as a second and data variable as the optional third argument. If that data argument was provided it is then passed to the callback function when the time comes for the pool object to get destroyed.

$s->register_cleanup はサーバオブジェクトのかわりに最初の引数としてプールオブジェクトを, 2 番目の引数としてコールバックファンクションをオプションの 3 番目の引数としてデータ変数を受け入れる APR::Pool::cleanup_register() でリプレイスされました。そのデータ引数が提供された場合プールオブジェクトを破棄するときがくるとそれはその後にコールバックファンクションに渡されます。

use Apache2::ServerUtil ();
sub cleanup_callback {
my $data = shift;
# your code comes here
return Apache2::Const::OK;
}
$s->pool->cleanup_register(\&cleanup_callback, $data);

See also PerlChildExitHandler.

In order to register a cleanup handler to be run only once when the main server (not each child process) shuts down, you can register a cleanup handler with server_shutdown_cleanup_register().

メインサーバ (各 child (# 子) プロセスではなく) がシャットダウンしたときに 1 度だけ走るクリーンアップハンドラを登録するために, あなたは server_shutdown_cleanup_register() で登録できます。


$s->uid


See the next entry.

次のエントリを参照してください。


$s->gid


apache-1.3 had server_rec records for server_uid and server_gid. httpd-2.0 doesn't have them, because in httpd-2.0 the directives User and Group are platform specific. And only UNIX supports it: http://httpd.apache.org/docs-2.0/mod/mpm_common.html#user

apache-1.3 は server_uid と server_gid の server_rec レコードをもっていました。httpd-2.0 ではディレクティブ User と Group がプラットフォーム固有なので httpd-2.0 はそれらをもっていません。そして UNIX だけがこれをサポートします: http://httpd.apache.org/docs-2.0/mod/mpm_common.html#user
It's possible to emulate mod_perl 1.0 API doing:

これはこのようにして mod_perl 1.0 API をエミュレートできます:

sub Apache2::Server::uid { $< }
sub Apache2::Server::gid { $( }

but the problem is that if the server is started as root, but its child processes are run under a different username, e.g. nobody, at the startup the above function will report the uid and gid values of root and not nobody, i.e. at startup it won't be possible to know what the User and Group settings are in httpd.conf.

しかし問題はサーバが root としてスタートされているが, その child プロセスが異なる username のもとで走っている場合で, e.g. nobody, スタートアップで上記ファンクションは nobody でなく root の uid と gid をリポートします, i.e. スタートアップでは httpd.conf で設定した User と Group を知ることができません。
META: though we can probably access the parsed config tree and try to fish these values from there. The real problem is that these values won't be available on all platforms and therefore we should probably not support them and let developers figure out how to code around it (e.g. by using $< and $().

META: けれども私たちはおそらくパースされた構成ツリーにアクセスできてそこからこれらの値の取得をトライできます。本当の問題はこれらの値がすべてのプラットフォームでは利用可能にならないことでありしたがって私たちはおそらくこれをサポートするべきでなく開発者にこれをどうにか回避するコードを見つけ出してもらうことです (e.g. $< と $( を使って)。


リクエストオブジェクトメソッド : Request Object Methods




$r->print



$r->print($foo);

or

print $foo;

no longer accepts a reference to a scalar as it did in mod_perl 1.0. This optimisation is not needed in the mod_perl 2.0's implementation of print.

もはや mod_perl 1.0 でされていたようにスカラへのリファレンスを受けいれません。この最適化は mod_perl 2.0 での print の実装では必要とされていません。


$r->cgi_env


See the next item

次のアイテムを参照してください。


$r->cgi_var


$r->cgi_env and $r->cgi_var should be replaced with $r->subprocess_env, which works identically in both mod_perl generations.

$r->cgi_env と $r->cgi_var は $r->subprocess_env でリプレイスしなければなりません, これは両方の mod_perl ジェネレーションで同じように機能します。


$r->current_callback


$r->current_callback is now simply a ModPerl::Util::current_callback and can be called for any of the phases, including those where $r simply doesn't exist.

$r->current_callback は今はシンプルに ModPerl::Util::current_callback で $r がまったく存在しない場面も含めて, どのフェーズでも呼びだすことができます。
Apache2::compat implements $r->current_callback for backwards compatibility.

Apache2::compat は後方互換のために $r->current_callback を実装しています。


$r->cleanup_for_exec


$r->cleanup_for_exec wasn't a part of the mp1 core API, but lived in a 3rd party module Apache2::SubProcess. That module's functionality is now a part of mod_perl 2.0 API. But Apache 2.0 doesn't need this function any longer.

$r->cleanup_for_exec は mp1 のコア API の一部ではありませんでしたが, 3rd パーティモジュール Apache2::SubProcess に存在していました。そのモジュールの機能は mod_perl 2.0 API の一部になりました。しかしもはや Apache 2.0 はこのファンクションを必要としません。
Apache2::compat implements $r->cleanup_for_exec for backwards compatibility as a NOOP.

Apache2::compat は後方互換のために NOOP (# no operation) として $r->cleanup_for_exec を実装しています。

See also the Apache2::SubProcess manpage.


$r->get_remote_host


get_remote_host() is now invoked on the connection object:

get_remote_host() はコネクションオブジェクトで呼びだされるようになりました。

use Apache2::Connection;
$r->connection->get_remote_host();

$r->get_remote_host is available through Apache2::compat.

$r->get_remote_host は Apache2::comapt をとおして利用可能です。


$r->content


See the next item.

次のアイテムを参照してください。


$r->args in an Array Context


$r->args in 2.0 returns the query string without parsing and splitting it into an array. You can also set the query string by passing a string to this method.

2.0 で $r->args はクエリストリングをパースも配列への分割もせずに返します。あなたはこのメソッドに文字列を渡すことでクエリストリングをセットすることもできます。
$r->content and $r->args in an array context were mistakes that never should have been part of the mod_perl 1.0 API. There are multiple reason for that, among others:

配列コンテキストでの $r->content と $r->args は mod_perl 1.0 API には決してなるべきではない間違いでした。それには複数の理由があります, なかでも:

  • does not handle multi-value keys

    multi-value のキーを処理しない

  • does not handle multi-part content types

    multi-part のコンテンツタイプを処理しない

  • does not handle chunked encoding

    chunked encoding を処理しない

  • slurps $r->headers_in->{'content-length'} into a single buffer (bad for performance, memory bloat, possible dos attack, etc.)

    $r->headers_in->{'content-length'} を単一のバッファに丸のみする (パフォーマンスの悪化, メモリ膨張, dos アタックの可能性, etc.)

  • in general duplicates functionality (and does so poorly) that is done better in Apache2::Request.

    一般的に Apache2::Request でベターに実行される機能を複製する (そしてそれはとても不十分)。

  • if one wishes to simply read POST data, there is the more modern filter API, along with continued support for read(STDIN, ...) and $r->read($buf, $r->headers_in->{'content-length'})

    シンプルに POST データを読みたい場合は, read(STDIN, ...) と $r->read($buf, $r->headers_in->{'content-lneght'}) の継続的なサポートとともに, よりモダンなフィルタ API がある


You could use CGI.pm or the code in Apache2::compat (it's slower).

あなたは CGI.pm や Apache2::compat のコードを使うこともできます (遅いですが)。
However, now that Apache2::Request has been ported to mod_perl 2.0 you can use it instead and reap the benefits of the fast C implementations of these functions. For documentation on its uses, please see:

しかし, Apache2::Request が mod_perl 2.0 に移植されたのであなたはかわりにこれを使いこれらのファンクションの高速な C 実装の利益を獲得できます。その使い方のドキュメントは, 参照してください:

http://httpd.apache.org/apreq
(# http://httpd.apache.org/apreq/docs/libapreq2)

$r->chdir_file


chdir() cannot be used in the threaded environment, therefore $r->chdir_file is not in the mod_perl 2.0 API.

For more information refer to: Threads Coding Issues Under mod_perl.

chdir() はスレッド化された環境で使えません, したがって $r->chdir_file は mod_perl 2.0 API にはありません。

詳細のために参照してください: Threads Coding Issues Under mod_perl


$r->is_main


$r->is_main is not part of the mod_perl 2.0 API. Use !$r->main instead.

Refer to the Apache2::RequestRec manpage.

$r->is_main は mod_perl 2.0 API の一部ではありません。かわりに !$r->main を使います。

Apache2::RequestRec man ページを参照してください。


$r->filename


When a new $r->filename is assigned Apache 2.0 doesn't update the finfo structure like it did in Apache 1.3. If the old behavior is desired Apache2::compat's overriding can be used. Otherwise one should explicitly update the finfo struct when desired as explained in the filename API entry.

新しい $r->filename がアサインされた Apache 2.0 は finfo 構造を Apache 1.3 でされるようにはアップデートしません。古い動作を望む場合は Apache2::compat のオーバーライドが使えます。そうでなければ filename API エントリで説明されているように希望するときに明示的に finfo 構造をアップデートする必要があります。


$r->finfo


As Apache 2.0 doesn't provide an access to the stat structure, but hides it in the opaque object $r->finfo now returns an APR::Finfo object. You can then invoke the APR::Finfo accessor methods on it.

Apache 2.0 では stat 構造へのアクセスを提供していませんが, それを不透明なオブジェクトに隠し $r->finfo が APR::Finfo オブジェクトを返すようになりました。それからあなたはその上で APR::Finfo アクセサメソッドを呼びだせます。
It's also possible to adjust the mod_perl 1.0 code using Apache2::compat's overriding. For example:

Apache2::compat のオーバーライドをつかって mod_perl 1.0 コードを調整することも可能です。例えば:

use Apache2::compat;
Apache2::compat::override_mp2_api('Apache2::RequestRec::finfo');
my $is_writable = -w $r->finfo;
Apache2::compat::restore_mp2_api('Apache2::RequestRec::finfo');

which internally does just the following:

これは内部的にちょうど次のようなことを行います:

stat $r->filename and return \*_;

So may be it's easier to just change the code to use this directly, so the above example can be adjusted to be:

ですからこれを直接使うようにコードを変更すると簡単になるかもしれません, そのため上記例はこのように調整できます:

my $is_writable = -w $r->filename;

with the performance penalty of an extra stat() system call. If you don't want this extra call, you'd have to write:

外部 stat() システムコールのパフォーマンスペナルティ付きです。あなたがこの外部コールを望まないなら, あなたはこのように書く必要があります:

use APR::Finfo;
use Apache2::RequestRec;
use APR::Const -compile => qw(WWRITE);
my $is_writable = $r->finfo->protection & APR::WWRITE,


See the APR::Finfo manpage for more information.


$r->notes


Similar to headers_in(), headers_out() and err_headers_out() in mod_perl 2.0, $r->notes() returns an APR::Table object, which can be used as a tied hash or calling its get() / set() / add() / unset() methods.

mod_perl 2.0 の headers_in(), headers_out() それから err_headers_out() と同様に, $r->notes() は APR::Table オブジェクトを返し, それは tie されたハッシュとして使ったりその get() / set() / add() /unset() メソッドを呼びだせます。
It's also possible to adjust the mod_perl 1.0 code using Apache2::compat's overriding:

これはまた Apache2::compat のオーバーライドを使って mod_perl 1.0 を調整することも可能です:

use Apache2::compat;
Apache2::compat::override_mp2_api('Apache2::RequestRec::notes');
$r->notes($key => $val);
$val = $r->notes($key);
Apache2::compat::restore_mp2_api('Apache2::RequestRec::notes');


See the Apache2::RequestRec manpage.


$r->header_in



See $r->err_header_out.


$r->header_out



See $r->err_header_out.


$r->err_header_out


header_in(), header_out() and err_header_out() are not available in 2.0. Use headers_in(), headers_out() and err_headers_out() instead (which should be used in 1.0 as well). For example you need to replace:

header_in(), header_out() それから err_header_out() は 2.0 で利用できません。かわりに headers_in(), headers_out() それから err_headers_out() を使います (これは 1.0 でも使えるはずです)。例えばあなたはこのようなリプレイスが必要です:

$r->err_header_out("Pragma" => "no-cahce");

with:

これでリプレイス:

$r->err_headers_out->{'Pragma'} = "no-cache";


See the Apache2::RequestRec manpage.


$r->register_cleanup


Similarly to $s->register_cleanup, $r->register_cleanup has been replaced with APR::Pool::cleanup_register() which accepts the pool object as the first argument instead of the request object. e.g.:

$s->register_cleanup と同様に, $r->register_cleanup はリクエストオブジェクトのかわりに最初の引数としてプールオブジェクトを受けいれる APR::Pool::cleanup_register() でリプレイスされました。e.g.:

sub cleanup_callback { my $data = shift; ... }
$r->pool->cleanup_register(\&cleanup_callback, $data);

where the last argument $data is optional, and if supplied will be passed as the first argument to the callback function.

最後の引数にある $data はオプションで, それが供給されるとコールバックファンクションの最初の引数として渡されます。

See the APR::Pool manpage.


$r->post_connection


$r->post_connection has been replaced with:

$r->post_connection はこれでリプレイスされました:

$r->connection->pool->cleanup_register();


See the APR::Pool manpage.


$r->request



Use Apache2::RequestUtil->request.


$r->send_fd


mod_perl 2.0 provides a new method sendfile() instead of send_fd, so if your code used to do:

mod_perl 2.0 は send_fd のかわりに新しいメソッド sendfile() を提供しますので, あなたのコードがこれを使っているなら:

open my $fh, "<$file" or die "$!";
$r->send_fd($fh);
close $fh;

now all you need is:

あなたはこれが必要になります:

$r->sendfile($file);

There is also a compatibility implementation of send_fd in pure perl in Apache2::compat.

Apache2::compat ではピュア perl の send_fd の互換実装もあります。
XXX: later we may provide a direct access to the real send_fd. That will be possible if we figure out how to portably convert PerlIO/FILE into apr_file_t (with help of apr_os_file_put, which expects a native filehandle, so I'm not sure whether this will work on win32).

XXX: 後々私たちはリアルな send_fd への直接アクセスを提供するかもしれません。それはあなたが PerlIO/FILE を apr_file_t にどうやって移植できるように変換するかを見つけられるようにします (ネイティブファイルハンドルを期待する, apr_os_file_put の助けによって, ですが私はこれが win32 で機能するかどうかはわかりません)。


$r->send_http_header


This method is not needed in 2.0, though available in Apache2::compat. 2.0 handlers only need to set the Content-type via $r->content_type($type).

このメソッドは 2.0 で不要ですが, Apache2::compat で利用可能です。2.0 のハンドラは $r->content_type($type) を介して Content-type をセットするだけです。


$r->server_root_relative


This method was replaced with Apache2::ServerUtil::server_root_relative() function and its first argument is a pool object. For example:

このメソッドは Apache2::ServerUtil::server_root_relative() ファンクションでリプレイスされていてその最初の引数はプールオブジェクトです。例えば:

# during request
$conf_dir = Apache2::server_root_relative($r->pool, 'conf');
# during startup
$conf_dir = Apache2::server_root_relative($s->pool, 'conf');

Note that the old form

古い形式に注意してください

my $conf_dir = Apache->server_root_relative('conf');

is no longer valid - server_root_relative() must be explicitly passed a pool.

これはもう無効です - server_root_relative() は明示的に pool が渡される必要があります。
The old functionality is available with Apache2::compat.

古い機能は Apache2::compat で利用可能です。


$r->hard_timeout



See $r->kill_timeout.


$r->reset_timeout



See $r->kill_timeout.


$r->soft_timeout



See $r->kill_timeout.


$r->kill_timeout


The functions $r->hard_timeout, $r->reset_timeout, $r->soft_timeout and $r->kill_timeout aren't needed in mod_perl 2.0. Apache2::compat implements these functions for backwards compatibility as NOOPs.

ファンクション $r->hard_timeout, $r->reset_timeout, $r->soft_timeout それから $r->kill_timeout は mod_perl 2.0 で不要になりました。Apache2::compat は後方互換のためにこれらのファンクションを NOOP として実装しています。


$r->set_byterange



See $r->each_byterange.


$r->each_byterange


The functions $r->set_byterange and $r->each_byterange aren't in the Apache 2.0 API, and therefore don't exist in mod_perl 2.0. The byterange serving functionality is now implemented in the ap_byterange_filter, which is a part of the core http module, meaning that it's automatically taking care of serving the requested ranges off the normal complete response. There is no need to configure it. It's executed only if the appropriate request headers are set. These headers aren't listed here, since there are several combinations of them, including the older ones which are still supported. For a complete info on these see modules/http/http_protocol.c.

ファンクション $r->set_byterange と $r->each_byterange は Apache 2.0 API ではなく, したがって mod_perl 2.0 では存在しません。byterange をサーブする機能はap_byterange_filter で実装されいて, これはコア http モジュールの一部であり, これは普通の完全なレスポンスからリクエストされたレンジを自動的にサーブしてくれることを意図しています。これを構成する必要はありません。これは適切なリクエストヘッダがセットされている場合でのみ実行されます。まだサポートされている古いものも含めていくつかの組み合わせがあるため, それらのヘッダはここにリストされていません。これらの完全な情報は modules/http/http_protocol.c を参照します。


Apache::Connection




$connection->auth_type


The record auth_type doesn't exist in the Apache 2.0's connection struct. It exists only in the request record struct. The new accessor in 2.0 API is $r->ap_auth_type.

レコード
Apache2::compat provides a back compatibility method, though it relies on the availability of the global Apache->request, which requires the configuration to have:

Apache2::compat は後方互換のメソッドを提供します, しかしながらグローバルの Apache->request が利用出来ることに依存しているため, それはこの構成が必要とされます:

PerlOptions +GlobalRequest

to set it up for earlier stages than response handler.

これはレスポンスハンドラより早い段階でセットアップします。


$connection->user


This method is deprecated in mod_perl 1.0 and $r->user should be used instead for both mod_perl generations. $r->user() method is available since mod_perl version 1.24_01.

このメソッドは mod_perl 1.0 では廃止予定で両方の mod_perl ジェネレーションでかわりに $r->user を使う必要があります。$r->user() メソッドは mod_perl バージョン 1.24_01 から利用可能です。


$connection->local_addr



See $connection->remote_addr


$connection->remote_addr


$c->local_addr and $c->remote_addr return an APR::SockAddr object and you can use this object's methods to retrieve the wanted bits of information, so if you had a code like:

$c->local_addr と $c->remote_addr は APR::SockAddr オブジェクトを返しあなたは必要とする情報の一部を取得するためにこのオブジェクトのメソッドを使えるので, もしあなたがこのようなコードをもっているなら:

use Socket 'sockaddr_in';
my $c = $r->connection;
my ($serverport, $serverip) = sockaddr_in($c->local_addr);
my ($remoteport, $remoteip) = sockaddr_in($c->remote_addr);

now it'll be written as:

これはこう書くようになります:

require APR::SockAddr;
my $c = $r->connection;
my $serverport = $c->local_addr->port;
my $serverip = $c->local_addr->ip_get;
my $remoteport = $c->remote_addr->port;
my $remoteip = $c->remote_addr->ip_get;

It's also possible to adjust the code using Apache2::compat's overriding:

これは Apache2::compat のオーバライドを使ったコードのアジャストも可能です:

use Socket 'sockaddr_in';
use Apache2::compat;

Apache2::compat::override_mp2_api('Apache2::Connection::local_addr');
my ($serverport, $serverip) = sockaddr_in($r->connection->local_addr');
Apache2::compat::restore_mp2_api('Apache2::Connection::local_addr');

Apache2::compat::override_mp2_api('Apache2::Connection::remote_addr');
my ($remoteport, $remoteip) = sockaddr_in($r->connection->remote_addr');
Apache2::compat::restore_mp2_api('Apache2::Connection::remote_addr');



Apache::File


The methods from mod_perl 1.0's module Apache::File have been either moved to other packages or removed.

mod_perl 1.0 のモジュール Apache::File からのメソッドは他のパッケージに移動されたか削除されたかのどちらかです。


new(), open() and close()


The methods new(), open() and close() were removed. See the back compatibility implementation in the module Apache2::compat.

メソッド new(), open() それから close() は削除されました。モジュール Apache2::compat の後方互換の実装を参照してください。
Because of that some of the idioms have changes too. If previously you were writing:

そのため一部のイディオムも変更されています。あなたが以前これを書いているなら:

my $fh = Apache::File->new($r->filename)
or return Apache::DECLINED;
# Slurp the file (hopefuly it's not too big);
my $content = do { local $/; <$fh> };
close $fh;

Now, you would write that using Apache2::RequestUtil::slurp_filename():

今, あなたは Apachce2::RequestUtil::slurp_filename() をつかってそれを書きます:

use Apache2::RequestUtil ();
my $content = ${ $r->slurp_filename() };



tmpfile()


The method tmpfile() was removed since Apache 2.0 doesn't have the API for this method anymore.

メソッド tmpfile() は Apache 2.0 がこのメソッドのための API をもうもっていないので削除されました。
See File::Temp, or the back compatibility implementation in the module Apache2::compat.

File::Temp, またはモジュール Apache2::compat の後方互換の実装を参照してください。
With Perl v5.8.0 you can create anonymous temporary files:

Perl v5.8.0 であなたは無名のテンポラリファイルを作成できます:

open $fh, "+>", undef or die $!;

That is a literal undef, not an undefined value.

これはリテラルの undef で, 未定義値ではありません。


Apache::Util


A few Apache2::Util functions have changed their interface.

いくつかの Apache2::Util ファンクションはそのインターフェイスが変更されています。


Apache::Util::size_string()


Apache::Util::size_string() has been replaced with APR::String::format_size(), which returns formatted strings of only 4 characters long.

Apache::Util::size_string() は APR::String::format_size() でリプレイスされました, これは 4 文字長のみのフォーマットされた文字列を返します。


Apache::Util::escape_uri()


Apache::Util::escape_uri() has been replaced with Apache2::Util::escape_path() and requires a pool object as a second argument. For example:

Apache::Util::escape_uri() は Apache2::Util::escape_path() でリプレイスされ 2 番目の引数としてプールオブジェクトを必要とします。例えば:

$escaped_path = Apache2::Util::escape_path($path, $r->pool);



Apache::Util::unescape_uri()


Apache::Util::unescape_uri() has been replaced with Apache2::URI::unescape_url().

Apache::Util::unescape_uri() は Apache2::URI::unescape_url() でリプレイスされました。


Apache::Util::escape_html()


Apache::Util::escape_html is not available in mod_perl 2.0. Use HTML::Entities instead (http://search.cpan.org/dist/HTML-Parser/lib/HTML/Entities.pm).

Apache::Util::escape_html は mod_perl 2.0 では利用できません。かわりに HTML::Entities を使います (http://search.cpan.org/dist/HTML-Parser/lib/HTML/Entities.pm)。
It's also available via Apache2::compat for backwards compatibility.

これは後方互換のための Apache2::compat を介して利用することもできます。


Apache::Util::parsedate()


Apache::Util::parsedate() has been replaced with APR::Date::parse_http().

Apache::Util::parsedate() は APR::Date::parse_http() でリプレイスされました。


Apache::Util::ht_time()


Apache2::Util::ht_time() now requires a pool object as a first argument.

For example:

Apache2::Util::ht_time は最初の引数としてプールオブジェクトを要求するようになりました。

例えば:

use Apache2::Util ();
$fmt = '%a, %d %b %Y %H:%M:%S %Z';
$gmt = 1;
$fmt_time = Apache2::Util::ht_time($r->pool, time(), $fmt, $gmt);

See the Apache2::Util manpage.
It's also possible to adjust the mod_perl 1.0 code using Apache2::compat's overriding.

For example:

Apache2::compat のオーバーライドを使って mod_perl 1.0 のコードを調整することもできます。

例えば:

use Apache2::compat;
Apache2::compat::override_mp2_api('Apache2::Util::ht_time');
$fmt_time = Apache2::Util::ht_time(time(), $fmt, $gmt);
Apache2::compat::restore_mp2_api('Apache2::Util::ht_time');



Apache::Util::validate_password()


Apache::Util::validate_password()
has been replaced with APR::Util::password_validate(). For example:

Apache::Util::validate_password() は APR::Util::password_validate() でリプレイスされました。例えば:

my $ok = Apache2::Util::password_validate("stas", "ZeO.RAc3iYvpA");



Apache::URI




Apache::URI->parse($r, [$uri])


parse() and its associated methods have moved into the APR::URI package. For example:

parse() とそれに関連するメソッドは APR::URI パッケージに移動しました。例えば:

my $curl = $r->construct_url;
APR::URI->parse($r->pool, $curl);

See the APR::URI manpage.


unparse()


Other than moving to the package APR::URI, unparse is now protocol-agnostic. Apache won't use http as the default protocol if hostname was set, but scheme wasn't not. So the following code:

APR::URI パッケージに移動したもの以外は, unparse はプロトコルに依存しなくなりました。Apache は hostname がセットされているとデフォルトのプロトコルとして http を使いませんが, スキーマはそうではありません。ですから次のコードは:

# request http://localhost.localdomain:8529/TestAPI::uri
my $parsed = $r->parsed_uri;
$parsed->hostname($r->get_server_name);
$parsed->port($r->get_server_port);
print $parsed->unparse;

prints:

プリントします:

//localhost.localdomain:8529/TestAPI::uri

forcing you to make sure that the scheme is explicitly set. This will do the right thing:

これはあなたにスキーマが明示的にセットされているか確認することを強制します。これが正しいことをします:

# request http://locahost.localdomain:8529/TestAPI::uri
my $parsed = $r->parsed_uri;
$parsed->hostname($r->get_server_name);
$parsed->port($r->get_server_port);
$parsed->scheme('http');
print $parsed->unparse;

prints:

プリントします:

http://localhost.localdomain:8529/TestAPI::uri

See the APR::URI manpage for more information.

詳細は APR::URI man ページを参照してください。
It's also possible to adjust the behavior to be mod_perl 1.0 compatible using Apache2::compat's overriding, in which case unparse() will transparently set scheme to http.

Apache2::compat のオーバーライドを使って mod_perl 1.0 互換の振る舞いに調整することも可能で, このケースで unparse() は透過的にスキームを http にセットします。

# request http://locahost.localdomain:8529/TestAPI::uri
Apache2::compat::override_mp2_api('APR::URI::unparse';
my $parsed = $r->parsed_uri;
# set hostname, but not the scheme
$parsed->hostname($r->get_server_name);
$parsed->port($r->get_server_port);
print $parsed->unparse;
Apache2::compat::restore_mp2_api('APR::URI::unparse');

prints:

プリントします:

http://localhost.localdomain:8529/TestAPI::uri



種々雑多 : Miscellaneous




メソッドハンドラ : Method Handlers


In mod_perl 1.0 the method handlers could be specified by using the ($$) prototype:

mod_perl 1.0 でメソッドハンドラは ($$) プロトタイプを使うことで指定されていました:

package Bird;
@ISA = qw(Eagle);

sub handler ($$) {
my ($class, $r) = @_;
...;
}

mod_perl 2.0 doesn't handle callbacks with ($$) prototypes differently than other callbacks (as it did in mod_perl 1.0), mainly because several callbacks in 2.0 have more arguments than just $r, so the ($$) prototype doesn't make sense anymore. Therefore if you want your code to work with both mod_perl generations and you can allow the luxury of:

mod_perl 2.0 は他のコールバックと違い (mod_perl 1.0 でされていたように) ($$) プロトタイプでコールバックを処理しません, 主な理由は 2.0 のいくつかのコールバックが $r だけでない多くの引数を持っているからで, ($$) プロトタイプはもう意味がないのです。したがってあなたが貴方のコードを mod_perl ジェネレーションの両方で機能させたい場合あなたは贅沢にこれをすることができます:

require 5.6.0;

or if you need the code to run only on mod_perl 2.0, use the method subroutine attribute. (The subroutine attributes are supported in Perl since version 5.6.0.)

またはあなたが mod_perl 2.0 でのみコードを走らせたい場合は, サブルーチンアトリビュート method を使います。(サブルーチンアトリビュートは Perl バージョン 5.6.0 からサポートされています。)
Here is the same example rewritten using the method subroutine attribute:

こちらはサブルーチンアトリビュート method をつかってリライトした同じ例です:

package Bird;
@ISA = qw(Eagle);

sub handler : method {
my ($class, $r) = @_;
...;
}

See the attributes manpage.

attributes man ページを参照してください。
If Class->method syntax is used for a Perl*Handler, the :method attribute is not required.

Class->method シンタクスが Perl*Handler で使われる場合, :method アトリビュートは不要です。
The porting tutorial provides examples on how to use the same code base under both mod_perl generations when the handler has to be a method.

移植チュートリアルはハンドラをメソッドにしなければならないときに mod_perl ジェネレーションの両方のもとで同じコードベースをどのように使うかの例を提供します。


スタックハンドラ : Stacked Handlers


Both mod_perl 1.0 and 2.0 support the ability to register more than one handler in each runtime phase, a feature known as stacked handlers. For example,

スタックハンドラとして知られている機能である, 各ランタイムフェーズで複数のハンドラを登録する能力を mod_perl 1.0 と 2.0 の両方はサポートしています。例えば,

PerlAuthenHandler My::First My::Second

The behavior of stacked Perl handlers differs between mod_perl 1.0 and 2.0. In 2.0, mod_perl respects the run-type of the underlying hook - it does not run all configured Perl handlers for each phase but instead behaves in the same way as Apache does when multiple handlers are configured, respecting (or ignoring) the return value of each handler as it is called.

スタックされた Perl ハンドラの振る舞いは mod_perl 1.0 と 2.0 の間で異なります。2.0 では, mod_perl は下部のフックのランタイプを尊重します - 各フェーズのために構成されたすべての Perl ハンドラは走りませんがかわりにそれが呼ばれた各ハンドラの値を尊重 (または無視) して複数のハンドラが構成されたときに Apache がするのと同じ方法で振る舞います。
See Stacked Handlers for a complete description of each hook and its run-type.

各フックとそのランタイプの完全な説明のために Stacked Handlers を参照してください。


Apache::src


For those who write 3rd party modules using XS, this module was used to supply mod_perl specific include paths, defines and other things, needed for building the extensions. mod_perl 2.0 makes things transparent with ModPerl::MM.

XS を使って 3rd パーティモジュールを書く人々のために, このモジュールは拡張の構築に必要とされる mod_perl 固有のインクルードパス, 定義やその他のものを供給するために使われていました。mod_perl 2.0 は ModPerl::MM でものごとを透過的にします。
Here is how to write a simple Makefile.PL for modules wanting to build XS code against mod_perl 2.0:

こちらは mod_perl 2.0 に対して XS コードのビルドを必要とするモジュールのためのシンプルな Makefile.PL を書く方法です:

use mod_perl 2.0
use ModPerl::MM ();

ModPerl::MM::WriteMakefile(
NAME => "Foo",
);

and everything will be done for you.

META: we probably will have a compat layer at some point.

META: move this section to the devel/porting and link there instead

そしてあなたのためにすべてが行われます。

META: 私たちはおそらくいくつかのポイントで互換レイヤをもちます。

META: このセクションを the devel/porting に移動してかわりにそこへリンクする


Apache::Table


Apache::Table has been renamed to APR::Table.

Apache::Table APR::Table にリネームされました。


Apache::SIG


Apache::SIG currently exists only Apache2::compat and it does nothing.

Apache::SIG は現在 Apache2::compat でのみ存在しそれはなにもしません。


Apache::StatINC


Apache::StatINC has been replaced by Apache2::Reload, which works for both mod_perl generations. To migrate to Apache2::Reload simply replace:

Apache::StatINC は Apache2::Reload によりリプレイスされ, それは mod_perl ジェネレーションの両方で機能します。Apache2::Reload に移行するためにはシンプルにリプレイスします:

PerlInitHandler Apache::StatINC

with:

これを以下で:

PerlInitHandler Apache2::Reload

However Apache2::Reload provides an extra functionality, covered in the module's manpage.

しかし Apache2::Reload はこのモジュールの man ページでカバーされている, 追加の機能を提供します。


メンテナ : Maintainers


Maintainer is the person(s) you should contact with updates, corrections and patches.
  • Stas Bekman [http://stason.org/]



作者 : Authors


  • Stas Bekman [http://stason.org/]

Only the major authors are listed above. For contributors see the Changes file.


NEXT



次回は、「 Introducing mod_perl Handlers 」を「 mod_perl 」公式サイト (https://perl.apache.org/index.html) より確認します。


参考情報は書籍「 続・初めての Perl 改訂版 」, 「 Effective Perl 第 2 版 」を中心に perldoc, Wikipedia および各 Web サイト。それと詳しい先輩。

目次 - Perl Index












































同じカテゴリー(Perl)の記事
 Perl mp2 翻訳 Web コンテンツ圧縮の FAQ (d228) (2023-10-11 23:49)
 Perl mp2 翻訳 既知のブラウザのバグの回避策をいくつか (d227) (2023-05-26 15:41)
 Perl mp2 翻訳 Perl と Apache でのキュートなトリック (d226) (2023-05-19 17:05)
 Perl mp2 翻訳 テンプレートシステムの選択 (d225) (2022-08-15 22:23)
 Perl mp2 翻訳 大規模 E コマースサイトの構築 (d224) (2022-06-15 20:43)
 Perl mp2 翻訳 チュートリアル (d223) (2022-06-15 20:42)
上の画像に書かれている文字を入力して下さい
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。

Llama
リャマ
TI-DA
てぃーだブログ
プロフィール
セラ (perlackline)
セラ (perlackline)
QRコード
QRCODE
オーナーへメッセージ

PAGE TOP ▲