[mp2] borked example in configuration docs

[mp2] borked example in configuration docs

am 21.01.2009 00:15:37 von Kevin Field

http://perl.apache.org/docs/2.0/user/config/custom.html

The example under the heading 'Creating and Using Custom Configuration
Directives', if copied verbatim, produces the following error when you
run httpd -t:

Can't locate object method "MyOtherParameter" via package
"MyApache2::MyParameters".\n

It took me a long time to figure this out, since, being a newbie, I
thought the example would actually work out of the box, so I
immediately jumped to making a pared-down version of it that only
included something like MyOtherParameter with no callback, because the
example seems to imply that this is possible, i.e., that somehow a
default MyOtherParameter sub will be made/faked that does something
like the code near the bottom of the document does:

sub MyOtherParameter { set_val('MyOtherParameter', @_) }

sub set_val {
my ($key, $self, $parms, $arg) = @_;
$self->{$key} = $arg;
unless ($parms->path) {
my $srv_cfg = Apache2::Module::get_config($self,
$parms->server);
$srv_cfg->{$key} = $arg;
}
}

Of course, you might glean this from the text under the heading 'func':

In our example with MyOtherParameter, mod_perl will use:

__PACKAGE__ . '::MyOtherParameter'

as a name of a subroutine and it anticipates that it exists in that
package.

....but as a newbie I get confused at statements like this, because
::MyOtherParameter doesn't actually exist in the example. In fact, the
first time I read it, I automatically generalized it in my mind, and
assumed there must be somewhere else in the docs that would explain the
default behaviour I had assumed to exist from the example, so I went
off fruitlessly looking for that.

So...maybe it's just me, but I feel like it would've been helpful to
note in the example something like:

# and we'd have to define sub MyOtherParameter (see 'func' below)

And anyway, why isn't there such a default if MyOtherParameter doesn't
exist?