You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs-cvs@perl.apache.org by st...@apache.org on 2005/09/21 00:11:22 UTC
svn commit: r290575 -
/perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod
Author: stas
Date: Tue Sep 20 15:11:15 2005
New Revision: 290575
URL: http://svn.apache.org/viewcvs?rev=290575&view=rev
Log:
show how to validate args and get the file:line of the directive info
Modified:
perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod
Modified: perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod
URL: http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod?rev=290575&r1=290574&r2=290575&view=diff
==============================================================================
--- perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod (original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod Tue Sep 20 15:11:15 2005
@@ -74,7 +74,8 @@
Here is a very basic module that declares two new configuration
directives: C<MyParameter>, which accepts one or more arguments, and
-C<MyOtherParameter> which accepts a single argument.
+C<MyOtherParameter> which accepts a single argument. C<MyParameter>
+validates that its arguments are valid strings.
#file:MyApache2/MyParameters.pm
#-----------------------------
@@ -90,6 +91,7 @@
use Apache2::CmdParms ();
use Apache2::Module ();
+ use Apache2::Directive ();
my @directives = (
{
@@ -108,6 +110,16 @@
sub MyParameter {
my ($self, $parms, @args) = @_;
$self->{MyParameter} = \@args;
+
+ # validate that the arguments are strings
+ for (@args) {
+ unless (/^\w+$/) {
+ my $directive = $parms->directive;
+ die sprintf "error: MyParameter at %s:%d expects " .
+ "string arguments: ('$_' is not a string)\n",
+ $directive->filename, $directive->line_num;
+ }
+ }
}
1;
---------------------------------------------------------------------
To unsubscribe, e-mail: docs-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-cvs-help@perl.apache.org