📄 modperl::registrycooker.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "mod_perl-2.0.2::docs::api::ModPerl::RegistryCooker 3".TH mod_perl-2.0.2::docs::api::ModPerl::RegistryCooker 3 "2005-10-21" "perl v5.10.0" "User Contributed Perl Documentation".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"ModPerl::RegistryCooker \- Cook mod_perl 2.0 Registry Modules.SH "Synopsis".IX Header "Synopsis".Vb 2\& # shouldn\*(Aqt be used as\-is but sub\-classed first\& # see ModPerl::Registry for an example.Ve.SH "Description".IX Header "Description"\&\f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR is used to create flexible and overridableregistry modules which emulate mod_cgi for Perl scripts. The conceptsare discussed in the manpage of the following modules:\&\f(CW\*(C`ModPerl::Registry\*(C'\fR, \f(CW\*(C`ModPerl::Registry\*(C'\fR and\&\f(CW\*(C`ModPerl::RegistryBB\*(C'\fR..PP\&\f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR has two purposes:.IP "\(bu" 4Provide ingredients that can be used by registry sub-classes.IP "\(bu" 4Provide a default behavior, which can be overriden in sub-classed.Sp\&\s-1META:\s0 in the future this functionality may move into a separate class..PPHere are the current overridable methods:.PP\&\s-1META:\s0 these are all documented in RegistryCooker.pm, though not usingpod. please help to port these to pod and move the descriptions here..IP "\(bu" 4\&\fInew()\fR.Spcreate the class's object, bless it and return it.Sp.Vb 1\& my $obj = $class\->new($r);.Ve.Sp\&\f(CW$class\fR \*(-- the registry class, usually \f(CW\*(C`_\|_PACKAGE_\|_\*(C'\fR can be used..Sp\&\f(CW$r\fR \*(-- \f(CW\*(C`Apache2::Request\*(C'\fR object..Spdefault: \fInew()\fR.IP "\(bu" 4\&\fIinit()\fR.Spinitializes the data object's fields: \f(CW\*(C`REQ\*(C'\fR, \f(CW\*(C`FILENAME\*(C'\fR,\&\f(CW\*(C`URI\*(C'\fR. Called from the \fInew()\fR..Spdefault: \fIinit()\fR.IP "\(bu" 4\&\fIdefault_handler()\fR.Spdefault: \fIdefault_handler()\fR.IP "\(bu" 4\&\fIrun()\fR.Spdefault: \fIrun()\fR.IP "\(bu" 4\&\fIcan_compile()\fR.Spdefault: \fIcan_compile()\fR.IP "\(bu" 4\&\fImake_namespace()\fR.Spdefault: \fImake_namespace()\fR.IP "\(bu" 4\&\fInamespace_root()\fR.Spdefault: \fInamespace_root()\fR.IP "\(bu" 4\&\fInamespace_from()\fR.SpIf \f(CW\*(C`namespace_from_uri\*(C'\fR is used and the script is called from thevirtual host, by default the virtual host name is prepended to the uriwhen package name for the compiled script is created. Sometimes thisbehavior is undesirable, e.g., when the same (physical) script isaccessed using the same path_info but different virtual hosts. In thatcase you can make the script compiled only once for all vhosts, byspecifying:.Sp.Vb 1\& $ModPerl::RegistryCooker::NameWithVirtualHost = 0;.Ve.SpThe drawback is that it affects the global environment and all otherscripts will be compiled ignoring virtual hosts..Spdefault: \fInamespace_from()\fR.IP "\(bu" 4\&\fIis_cached()\fR.Spdefault: \fIis_cached()\fR.IP "\(bu" 4\&\fIshould_compile()\fR.Spdefault: \fIshould_compile()\fR.IP "\(bu" 4\&\fIflush_namespace()\fR.Spdefault: \fIflush_namespace()\fR.IP "\(bu" 4\&\fIcache_table()\fR.Spdefault: \fIcache_table()\fR.IP "\(bu" 4\&\fIcache_it()\fR.Spdefault: \fIcache_it()\fR.IP "\(bu" 4\&\fIread_script()\fR.Spdefault: \fIread_script()\fR.IP "\(bu" 4\&\fIshebang_to_perl()\fR.Spdefault: \fIshebang_to_perl()\fR.IP "\(bu" 4\&\fIget_script_name()\fR.Spdefault: \fIget_script_name()\fR.IP "\(bu" 4\&\fIchdir_file()\fR.Spdefault: \fIchdir_file()\fR.IP "\(bu" 4\&\fIget_mark_line()\fR.Spdefault: \fIget_mark_line()\fR.IP "\(bu" 4\&\fIcompile()\fR.Spdefault: \fIcompile()\fR.IP "\(bu" 4\&\fIerror_check()\fR.Spdefault: \fIerror_check()\fR.IP "\(bu" 4\&\fIstrip_end_data_segment()\fR.Spdefault: \fIstrip_end_data_segment()\fR.IP "\(bu" 4\&\fIconvert_script_to_compiled_handler()\fR.Spdefault: \fIconvert_script_to_compiled_handler()\fR.Sh "Special Predefined Functions".IX Subsection "Special Predefined Functions"The following functions are implemented as constants..IP "\(bu" 4\&\s-1\fINOP\s0()\fR.SpUse when the function shouldn't do anything..IP "\(bu" 4\&\s-1\fITRUE\s0()\fR.SpUse when a function should always return a true value..IP "\(bu" 4\&\s-1\fIFALSE\s0()\fR.SpUse when a function should always return a false value..SH "Sub-classing Techniques".IX Header "Sub-classing Techniques"To override the default \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR methods, first,sub-class \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR or one of its existingsub-classes, using \f(CW\*(C`use base\*(C'\fR. Second, override the methods..PPThose methods that weren't overridden will be resolved at run timewhen used for the first time and cached for the future requests. Oneway to to shortcut this first run resolution is to use the symbolaliasing feature. For example to alias \f(CW\*(C`ModPerl::MyRegistry::flush_namespace\*(C'\fRas \f(CW\*(C`ModPerl::RegistryCooker::flush_namespace\*(C'\fR, you can do:.PP.Vb 5\& package ModPerl::MyRegistry;\& use base qw(ModPerl::RegistryCooker);\& *ModPerl::MyRegistry::flush_namespace =\& \e&ModPerl::RegistryCooker::flush_namespace;\& 1;.Ve.PPIn fact, it's a good idea to explicitly alias all the methods so youknow exactly what functions are used, rather then relying on thedefaults. For that purpose \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR class method\&\fIinstall_aliases()\fR can be used. Simply prepare a hash with method namesin the current package as keys and corresponding fully qualifiedmethods to be aliased for as values and pass it to\&\fIinstall_aliases()\fR. Continuing our example we could do:.PP.Vb 7\& package ModPerl::MyRegistry;\& use base qw(ModPerl::RegistryCooker);\& my %aliases = (\& flush_namespace => \*(AqModPerl::RegistryCooker::flush_namespace\*(Aq,\& );\& _\|_PACKAGE_\|_\->install_aliases(\e%aliases);\& 1;.Ve.PPThe values use fully qualified packages so you can mix methods fromdifferent classes..SH "Examples".IX Header "Examples"The best examples are existing core registry modules:\&\f(CW\*(C`ModPerl::Registry\*(C'\fR, \f(CW\*(C`ModPerl::Registry\*(C'\fR and\&\f(CW\*(C`ModPerl::RegistryBB\*(C'\fR. Look at the source code and their manpagesto see how they subclass \f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR..PPFor example by default \f(CW\*(C`ModPerl::Registry\*(C'\fR uses the script's pathwhen creating a package's namespace. If for example you want to use auri instead you can override it with:.PP.Vb 3\& *ModPerl::MyRegistry::namespace_from =\& \e&ModPerl::RegistryCooker::namespace_from_uri;\& 1;.Ve.PPSince the \f(CW\*(C`namespace_from_uri\*(C'\fR component already exists in\&\f(CW\*(C`ModPerl::RegistryCooker\*(C'\fR. If you want to write your own method,e.g., that creates a namespace based on the inode, you can do:.PP.Vb 4\& sub namespace_from_inode {\& my $self = shift;\& return (stat $self\->[FILENAME])[1];\& }.Ve.PP\&\s-1META:\s0 when \f(CW$r\fR\->finfo will be ported it'll be more effecient. (stat \f(CW$r\fR\->finfo)[1].SH "Authors".IX Header "Authors"Doug MacEachern.PPStas Bekman.SH "See Also".IX Header "See Also"\&\f(CW\*(C`ModPerl::Registry\*(C'\fR,\&\f(CW\*(C`ModPerl::RegistryBB\*(C'\fR and\&\f(CW\*(C`ModPerl::PerlRun\*(C'\fR.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -