Philippe M. Chiasson wrote:
Attached is the small patch to remove the magicness of PerlLoadModule and add
Apache::Module::add() as discussed earlier.
excellent! a few minor comments below.
[...] + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
I suppose there is no point making those upcase anymore, since they aren't special (above and below / tests + docs). What do you think?
Think it's a very good idea, and I liked Geoff's suggestion of @directives instead.
Index: src/docs/2.0/api/Apache/CmdParms.pod
[...]
The extra information passed through C<cmd_data> in
-C<L<@APACHE_MODULE_COMMANDS|docs::2.0::user::config::custom/C_cmd_data_>>.
+C<L<@CMDS|docs::2.0::user::config::custom/C_cmd_data_>>.
but it's no longer passed in cmd_data user-wise. Shouldn't it link to Apache::Module::add() and the latter to cmd_data?
Yes, I guess it makes more sense that way.
[...] missing add() call?
Yup.
Index: src/docs/2.0/api/Apache/Const.pod[...]-=item * A global array C<@APACHE_MODULE_COMMANDS> for declaring thewrap the line?
-new directives and their behavior.
+=item * An array C<L<@CMDS|/C__CMDS_>> for declaring the new directives and their
+behavior.
+
+=item * A call to C<L<Apache::Module::add()|docs::2.0::api::Apache::Module/C_add_>> to register the new
+directives with apache.
Indeed.
[...]
may be add a note that @CMDS is not a special name and any other name will do?
That's a good idea. Added.
+=head2 Apache::Module::add()
Call it: "Activating the new directive" or "Registering ..." or something like that? Apache::Module::add() looks like an API entry, which is already defined elsewhere.
"Registering the new directives" is it.
--
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Index: Changes =================================================================== RCS file: /home/cvs/modperl-2.0/Changes,v retrieving revision 1.520 diff -u -I$Id -r1.520 Changes --- Changes 27 Oct 2004 22:48:29 -0000 1.520 +++ Changes 9 Nov 2004 03:03:02 -0000 @@ -12,6 +12,9 @@ =item 1.99_18-dev +Remove magicness of PerlLoadModule and implement Apache::Module::add() +for modules that implement their own configuration directives [Gozer] + Apache::Connection::remote_ip is now settable (needed to set the remote_ip record based on proxy's X-Forwarded-For header) [Stas] Index: todo/release =================================================================== RCS file: /home/cvs/modperl-2.0/todo/release,v retrieving revision 1.69 diff -u -I$Id -r1.69 release --- todo/release 25 Oct 2004 21:57:17 -0000 1.69 +++ todo/release 9 Nov 2004 03:03:02 -0000 @@ -46,11 +46,6 @@ See test TestAPR::pool http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=108547894817083&w=2 -* revamp directive handlers, expose modperl_module_add, fix - PerlLoadModule, etc. - http://marc.theaimsgroup.com/?t=108309295200003 - owner: geoff - * per-server cleanups core dump or are otherwise ineffective Apache->server->process->pconf->cleanup_register(sub { ... }); Report: geoff Index: src/modules/perl/modperl_cmd.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v retrieving revision 1.66 diff -u -I$Id -r1.66 modperl_cmd.c --- src/modules/perl/modperl_cmd.c 20 Sep 2004 18:14:48 -0000 1.66 +++ src/modules/perl/modperl_cmd.c 9 Nov 2004 03:03:03 -0000 @@ -630,8 +630,6 @@ */ MP_CMD_SRV_DECLARE(load_module) { - apr_pool_t *p = parms->pool; - server_rec *s = parms->server; const char *errmsg; MP_TRACE_d(MP_FUNC, "PerlLoadModule %s\n", arg); @@ -643,7 +641,7 @@ return errmsg; } - return modperl_module_add(p, s, arg); + return NULL; } /* propogate filters insertion ala SetInputFilter */ Index: src/modules/perl/modperl_module.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_module.c,v retrieving revision 1.18 diff -u -I$Id -r1.18 modperl_module.c --- src/modules/perl/modperl_module.c 9 Oct 2004 18:27:43 -0000 1.18 +++ src/modules/perl/modperl_module.c 9 Nov 2004 03:03:03 -0000 @@ -566,13 +566,6 @@ return APR_SUCCESS; } -static AV *modperl_module_cmds_get(pTHX_ module *modp) -{ - char *name = Perl_form(aTHX_ "%s::%s", modp->name, - "APACHE_MODULE_COMMANDS"); - return get_av(name, FALSE); -} - static const char *modperl_module_cmd_fetch(pTHX_ SV *obj, const char *name, SV **retval) { @@ -633,7 +626,7 @@ } static const char *modperl_module_add_cmds(apr_pool_t *p, server_rec *s, - module *modp) + module *modp, SV *mod_cmds) { const char *errmsg; apr_array_header_t *cmds; @@ -643,12 +636,8 @@ #ifdef USE_ITHREADS MP_dSCFG(s); dTHXa(scfg->mip->parent->perl); -#endif - - if (!(module_cmds = modperl_module_cmds_get(aTHX_ modp))) { - return apr_pstrcat(p, "module ", modp->name, - " does not define @APACHE_MODULE_COMMANDS", NULL); - } +#endif + module_cmds = (AV*)SvRV(mod_cmds); fill = AvFILL(module_cmds); cmds = apr_array_make(p, fill+1, sizeof(command_rec)); @@ -788,7 +777,7 @@ } const char *modperl_module_add(apr_pool_t *p, server_rec *s, - const char *name) + const char *name, SV *mod_cmds) { MP_dSCFG(s); #ifdef USE_ITHREADS @@ -834,7 +823,7 @@ modp->cmds = NULL; - if ((errmsg = modperl_module_add_cmds(p, s, modp))) { + if ((errmsg = modperl_module_add_cmds(p, s, modp, mod_cmds))) { return errmsg; } @@ -851,7 +840,7 @@ scfg->modules = apr_hash_make(p); } - apr_hash_set(scfg->modules, name, APR_HASH_KEY_STRING, modp); + apr_hash_set(scfg->modules, apr_pstrdup(p, name), APR_HASH_KEY_STRING, modp); #ifdef USE_ITHREADS /* Index: src/modules/perl/modperl_module.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_module.h,v retrieving revision 1.3 diff -u -I$Id -r1.3 modperl_module.h --- src/modules/perl/modperl_module.h 4 Mar 2004 06:01:07 -0000 1.3 +++ src/modules/perl/modperl_module.h 9 Nov 2004 03:03:03 -0000 @@ -21,7 +21,7 @@ void modperl_module_config_table_set(pTHX_ PTR_TBL_t *table); const char *modperl_module_add(apr_pool_t *p, server_rec *s, - const char *name); + const char *name, SV *mod_cmds); SV *modperl_module_config_get_obj(pTHX_ SV *pmodule, server_rec *s, ap_conf_vector_t *v); Index: xs/Apache/Module/Apache__Module.h =================================================================== RCS file: /home/cvs/modperl-2.0/xs/Apache/Module/Apache__Module.h,v retrieving revision 1.15 diff -u -I$Id -r1.15 Apache__Module.h --- xs/Apache/Module/Apache__Module.h 17 Sep 2004 00:07:24 -0000 1.15 +++ xs/Apache/Module/Apache__Module.h 9 Nov 2004 03:03:03 -0000 @@ -73,3 +73,25 @@ { return mod->minor_version; } + +static MP_INLINE void mpxs_Apache__Module_add(pTHX_ + char *package, + SV *cmds) +{ + const char *error; + server_rec *s; + + if (!(SvROK(cmds) && (SvTYPE(SvRV(cmds)) == SVt_PVAV))) { + Perl_croak(aTHX_ "Usage: Apache::Module::add(__PACKAGE__, [])"); + } + + s = modperl_global_get_server_rec(); + error = modperl_module_add(s->process->pconf, s, package, cmds); + + if (error) { + Perl_croak(aTHX_ "Apache::Module::add(%s) failed : %s", + package,error); + } + + return; +} Index: xs/maps/apache_functions.map =================================================================== RCS file: /home/cvs/modperl-2.0/xs/maps/apache_functions.map,v retrieving revision 1.105 diff -u -I$Id -r1.105 apache_functions.map --- xs/maps/apache_functions.map 4 Oct 2004 19:27:37 -0000 1.105 +++ xs/maps/apache_functions.map 9 Nov 2004 03:03:03 -0000 @@ -212,6 +212,7 @@ >ap_show_modules >ap_register_hooks mpxs_Apache__Module_loaded + mpxs_Apache__Module_add #ap_get_module_config mpxs_Apache__Module_get_config | | pmodule, s, v=NULL mpxs_Apache__Module_ap_api_major_version Index: xs/tables/current/ModPerl/FunctionTable.pm =================================================================== RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v retrieving revision 1.189 diff -u -I$Id -r1.189 FunctionTable.pm --- xs/tables/current/ModPerl/FunctionTable.pm 6 Oct 2004 17:55:08 -0000 1.189 +++ xs/tables/current/ModPerl/FunctionTable.pm 9 Nov 2004 03:03:03 -0000 @@ -2,7 +2,7 @@ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # ! WARNING: generated by ModPerl::ParseSource/0.01 -# ! Wed Oct 6 10:35:20 2004 +# ! Thu Nov 4 15:29:12 2004 # ! do NOT edit, any changes will be lost ! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -6169,6 +6169,28 @@ { 'type' => 'int', 'name' => 'query_code' + } + ] + }, + { + 'return_type' => 'void', + 'name' => 'mpxs_Apache__Module_add', + 'attr' => [ + 'static', + '__inline__' + ], + 'args' => [ + { + 'type' => 'PerlInterpreter *', + 'name' => 'my_perl' + }, + { + 'type' => 'char *', + 'name' => 'package' + }, + { + 'type' => 'SV *', + 'name' => 'cmds' } ] }, Index: t/response/TestCompat/apache_module.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache_module.pm,v retrieving revision 1.3 diff -u -I$Id -r1.3 apache_module.pm --- t/response/TestCompat/apache_module.pm 16 Sep 2004 16:32:08 -0000 1.3 +++ t/response/TestCompat/apache_module.pm 9 Nov 2004 03:03:03 -0000 @@ -11,11 +11,13 @@ use Apache::compat (); use Apache::Constants qw(OK); -our @APACHE_MODULE_COMMANDS = ( +my @directives = ( { name => 'TestCompatApacheModuleParms', }, ); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); sub TestCompatApacheModuleParms { my($self, $parms, $args) = @_; Index: t/response/TestDirective/cmdparms.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/cmdparms.pm,v retrieving revision 1.9 diff -u -I$Id -r1.9 cmdparms.pm --- t/response/TestDirective/cmdparms.pm 13 Sep 2004 23:02:35 -0000 1.9 +++ t/response/TestDirective/cmdparms.pm 9 Nov 2004 03:03:03 -0000 @@ -27,13 +27,15 @@ use constant KEY => "TestCmdParms"; -our @APACHE_MODULE_COMMANDS = ( +my @directives = ( { name => +KEY, cmd_data => 'cmd_data', errmsg => 'errmsg', }, ); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); my @methods = qw(cmd context directive info override path pool server temp_pool); Index: t/response/TestDirective/perlloadmodule.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlloadmodule.pm,v retrieving revision 1.6 diff -u -I$Id -r1.6 perlloadmodule.pm --- t/response/TestDirective/perlloadmodule.pm 13 Sep 2004 22:36:19 -0000 1.6 +++ t/response/TestDirective/perlloadmodule.pm 9 Nov 2004 03:03:03 -0000 @@ -11,7 +11,7 @@ use Apache::CmdParms (); use Apache::Module (); -our @APACHE_MODULE_COMMANDS = ( +my @directives = ( { name => 'MyTest', func => __PACKAGE__ . '::MyTest', @@ -31,6 +31,8 @@ } ); +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); + sub DIR_CREATE { my($class, $parms) = @_; @@ -52,7 +54,7 @@ sub DIR_MERGE { my $class = ref $_[0]; -# warn "$class->DIR_MERGE\n"; + warn "$class->DIR_MERGE\n"; merge(@_); } @@ -64,7 +66,7 @@ sub SERVER_CREATE { my($class, $parms) = @_; -# warn "$class->SERVER_CREATE\n"; + warn "$class->SERVER_CREATE\n"; return bless { name => __PACKAGE__, }, $class; Index: t/response/TestDirective/perlloadmodule2.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlloadmodule2.pm,v retrieving revision 1.7 diff -u -I$Id -r1.7 perlloadmodule2.pm --- t/response/TestDirective/perlloadmodule2.pm 13 Sep 2004 22:36:19 -0000 1.7 +++ t/response/TestDirective/perlloadmodule2.pm 9 Nov 2004 03:03:03 -0000 @@ -11,7 +11,7 @@ use Apache::CmdParms (); use Apache::Module (); -our @APACHE_MODULE_COMMANDS = ( +my @directives = ( { name => 'MyMergeTest', func => __PACKAGE__ . '::MyMergeTest', @@ -20,6 +20,8 @@ errmsg => 'Values that get merged', }, ); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); sub merge { my($base, $add) = @_; Index: t/response/TestDirective/perlloadmodule3.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlloadmodule3.pm,v retrieving revision 1.5 diff -u -I$Id -r1.5 perlloadmodule3.pm --- t/response/TestDirective/perlloadmodule3.pm 13 Sep 2004 22:36:19 -0000 1.5 +++ t/response/TestDirective/perlloadmodule3.pm 9 Nov 2004 03:03:03 -0000 @@ -16,12 +16,14 @@ use Apache::Const -compile => qw(OK); -our @APACHE_MODULE_COMMANDS = ( +my @directives = ( { name => 'MyPlus' }, { name => 'MyList' }, { name => 'MyAppend' }, { name => 'MyOverride' }, ); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); sub MyPlus { set_val('MyPlus', @_) } sub MyAppend { set_val('MyAppend', @_) } Index: t/response/TestDirective/perlloadmodule4.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlloadmodule4.pm,v retrieving revision 1.8 diff -u -I$Id -r1.8 perlloadmodule4.pm --- t/response/TestDirective/perlloadmodule4.pm 13 Sep 2004 22:36:19 -0000 1.8 +++ t/response/TestDirective/perlloadmodule4.pm 9 Nov 2004 03:03:03 -0000 @@ -26,7 +26,9 @@ use constant KEY => "MyTest4"; -our @APACHE_MODULE_COMMANDS = ({ name => +KEY },); +my @directives = ({ name => +KEY },); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); sub MyTest4 { my($self, $parms, $arg) = @_; Index: t/response/TestDirective/perlloadmodule5.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlloadmodule5.pm,v retrieving revision 1.7 diff -u -I$Id -r1.7 perlloadmodule5.pm --- t/response/TestDirective/perlloadmodule5.pm 13 Sep 2004 22:36:19 -0000 1.7 +++ t/response/TestDirective/perlloadmodule5.pm 9 Nov 2004 03:03:03 -0000 @@ -24,7 +24,9 @@ use constant KEY => "MyTest5"; -our @APACHE_MODULE_COMMANDS = ({ name => +KEY },); +my @directives = ({ name => +KEY },); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); sub MyTest5 { my($self, $parms, $arg) = @_; Index: t/response/TestDirective/perlloadmodule6.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlloadmodule6.pm,v retrieving revision 1.6 diff -u -I$Id -r1.6 perlloadmodule6.pm --- t/response/TestDirective/perlloadmodule6.pm 13 Sep 2004 22:36:19 -0000 1.6 +++ t/response/TestDirective/perlloadmodule6.pm 9 Nov 2004 03:03:03 -0000 @@ -14,7 +14,9 @@ use constant KEY => "MyTest6"; -our @APACHE_MODULE_COMMANDS = ({ name => +KEY },); +my @directives = ({ name => +KEY },); + +Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]); sub MyTest6 { my($self, $parms, $arg) = @_;
Index: src/docs/2.0/api/Apache/CmdParms.pod
===================================================================
RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/CmdParms.pod,v
retrieving revision 1.17
diff -u -I$Id -r1.17 CmdParms.pod
--- src/docs/2.0/api/Apache/CmdParms.pod 13 Sep 2004 22:17:03 -0000 1.17
+++ src/docs/2.0/api/Apache/CmdParms.pod 9 Nov 2004 02:50:13 -0000
@@ -8,15 +8,18 @@
=head1 Synopsis
use Apache::CmdParms ();
+ use Apache::Module ();
use Apache::Const -compile => qw(NOT_IN_LOCATION);
- our @APACHE_MODULE_COMMANDS = (
+ my @directives = (
{
name => 'MyDirective',
cmd_data => 'some extra data',
},
);
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
+
sub MyDirective {
my($self, $parms, $args) = @_;
@@ -35,8 +38,8 @@
# this command's directive object
$directive = $parms->directive;
- # the extra information passed thru cmd_data in
- # @APACHE_MODULE_COMMANDS
+ # the extra information passed thru cmd_data to
+ # Apache::Module::add()
$info = $parms->info;
# which methods are <Limit>ed ?
@@ -193,7 +196,7 @@
=head2 C<info>
The extra information passed through C<cmd_data> in
-C<L<@APACHE_MODULE_COMMANDS|docs::2.0::user::config::custom/C_cmd_data_>>.
+C<L<Apache::Module::add()|docs::2.0::api::Apache::Module/C_add_>>.
$info = $parms->info;
@@ -213,7 +216,7 @@
For example here is how to pass arbitrary information to a directive
subroutine:
- our @APACHE_MODULE_COMMANDS = (
+ my @directives = (
{
name => 'MyDirective1',
func => \&MyDirective,
@@ -225,6 +228,7 @@
cmd_data => 'Two',
},
);
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
sub MyDirective {
my($self, $parms, $args) = @_;
Index: src/docs/2.0/api/Apache/Const.pod
===================================================================
RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/Const.pod,v
retrieving revision 1.27
diff -u -I$Id -r1.27 Const.pod
--- src/docs/2.0/api/Apache/Const.pod 17 Sep 2004 19:28:15 -0000 1.27
+++ src/docs/2.0/api/Apache/Const.pod 9 Nov 2004 02:50:14 -0000
@@ -87,7 +87,7 @@
use Apache::Const -compile => qw(:cmd_how);
The C<:cmd_how> constants group is used in
-C<L<@APACHE_MODULE_COMMANDS|docs::2.0::user::config::custom/C_args_how_>>
+C<L<Apache::Module::add()|docs::2.0::api::Apache::Module/C_add_>>
and
C<L<$cmds-E<gt>args_how|docs::2.0::api::Apache::Command/C_args_how_>>.
Index: src/docs/2.0/api/Apache/Module.pod
===================================================================
RCS file: /home/cvs/modperl-docs/src/docs/2.0/api/Apache/Module.pod,v
retrieving revision 1.24
diff -u -I$Id -r1.24 Module.pod
--- src/docs/2.0/api/Apache/Module.pod 17 Sep 2004 00:07:23 -0000 1.24
+++ src/docs/2.0/api/Apache/Module.pod 9 Nov 2004 02:50:14 -0000
@@ -9,6 +9,13 @@
use Apache::Module ();
+ #Define a configuration directive
+ my @directives = (
+ name => 'MyDirective',
+ );
+
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
+
# iterate over the whole module list
for (my $modp = Apache::Module::top_module(); $modp; $modp = $modp->next) {
my $name = $modp->name;
@@ -62,6 +69,36 @@
=head1 API
C<Apache::Module> provides the following functions and/or methods:
+
+
+
+
+
+=head2 C<add>
+
+Add a module's custom configuration directive to Apache.
+
+ Apache::Module::add($package, $cmds);
+
+=over 4
+
+=item arg1: C<$package> ( string )
+
+the package of the module to add
+
+=item arg2: C<$cmds> ( ARRAY of HASH refs )
+
+the list of configuration directives to add
+
+=item ret: no return value
+
+=item since: 1.99_18
+
+=back
+
+See also L<Apache Server Configuration Customization in
+Perl|docs::2.0::user::config::custom>.
+
Index: src/docs/2.0/user/config/custom.pod
===================================================================
RCS file: /home/cvs/modperl-docs/src/docs/2.0/user/config/custom.pod,v
retrieving revision 1.14
diff -u -I$Id -r1.14 custom.pod
--- src/docs/2.0/user/config/custom.pod 14 Sep 2004 20:47:23 -0000 1.14
+++ src/docs/2.0/user/config/custom.pod 9 Nov 2004 02:50:14 -0000
@@ -91,7 +91,7 @@
use Apache::CmdParms ();
use Apache::Module ();
- our @APACHE_MODULE_COMMANDS = (
+ my @directives = (
{
name => 'MyParameter',
func => __PACKAGE__ . '::MyParameter',
@@ -103,6 +103,7 @@
name => 'MyOtherParameter',
},
);
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
sub MyParameter {
my($self, $parms, @args) = @_;
@@ -125,12 +126,16 @@
The following sections discuss this and more advanced modules in
detail.
-A minimal configuration module is comprised of two groups of elements:
+A minimal configuration module is comprised of three groups of elements:
=over
-=item * A global array C<@APACHE_MODULE_COMMANDS> for declaring the
-new directives and their behavior.
+=item * An array C<L<@directives|/C__CMDS_>> for declaring the new
+directives and their behavior.
+
+=item * A call to
+C<L<Apache::Module::add()|docs::2.0::api::Apache::Module/C_add_>> to
+register the new directives with apache.
=item * A subroutine per each new directive, which is called when the
directive is seen
@@ -139,13 +144,13 @@
-=head2 C<@APACHE_MODULE_COMMANDS>
+=head2 C<@directives>
-C<@APACHE_MODULE_COMMANDS> is a global array of hash references. Each
+C<@directives> is an array of hash references. Each
hash represents a separate new configuration directive. In our example
we had:
- our @APACHE_MODULE_COMMANDS = (
+ my @directives = (
{
name => 'MyParameter',
func => __PACKAGE__ . '::MyParameter',
@@ -169,6 +174,10 @@
I<L<args_how|/C_args_how_>>, I<L<req_override|/C_req_override_>> and
I<L<errmsg|/C_errmsg_>>. They are discussed in the following sections.
+It is worth noting that in previous versions of mod_perl, it was
+necessary to call this variable @APACHE_MODULE_COMMANDS. It is not
+the case anymore, and we consistently use the name @directives in
+the documentation for clarity. It can be named anything at all.
=head3 C<name>
@@ -274,7 +283,7 @@
you to store arbitrary strings for later retrieval from your
directive handler. For instance:
- our @APACHE_MODULE_COMMANDS = (
+ my @directives = (
{
name => '<Location',
# func defaults to Redirect()
@@ -313,6 +322,14 @@
chosen for a reason - this is exactly how httpd core handles these
two directives.
+=head2 Registering the new directives
+
+Once the C<L<@directives|/C__CMDS_>> array is populated, it needs to be
+registered with apache using
+C<L<Apache::Module::add()|docs::2.0::api::Apache::Module/C_add_>>
+
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
+
=head2 Directive Scope Definition Constants
The I<L<req_override|/C_req_override_>> attribute specifies the
@@ -780,7 +797,8 @@
...
use Apache::Module ();
use Apache::CmdParms ();
- our @APACHE_MODULE_COMMANDS = (...);
+ my @directives = (...);
+ Apache::Module::add(__PACKLAGE__, [EMAIL PROTECTED]);
...
sub SERVER_CREATE {
my($class, $parms) = @_;
@@ -860,7 +878,8 @@
...
use Apache::Module ();
use Apache::CmdParms ();
- our @APACHE_MODULE_COMMANDS = (...);
+ my @directives = (...);
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
...
sub DIR_CREATE {
my($class, $parms) = @_;
@@ -921,12 +940,13 @@
use Apache::Const -compile => qw(OK);
- our @APACHE_MODULE_COMMANDS = (
+ my @directives = (
{ name => 'MyPlus' },
{ name => 'MyList' },
{ name => 'MyAppend' },
{ name => 'MyOverride' },
);
+ Apache::Module::add(__PACKAGE__, [EMAIL PROTECTED]);
sub MyPlus { set_val('MyPlus', @_) }
sub MyAppend { set_val('MyAppend', @_) }
@@ -987,7 +1007,7 @@
__END__
It's probably a good idea to specify all the attributes for the
-C<@APACHE_MODULE_COMMANDS> entries, but here for simplicity we have
+C<@directives> entries, but here for simplicity we have
only assigned to the I<L<name|/C_name_>> directive, which is a
must. Since all our directives take a single argument,
C<L<Apache::TAKE1|/C_Apache__TAKE1_>>, the default
signature.asc
Description: OpenPGP digital signature
