perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r290575 - /perl/modperl/docs/trunk/src/docs/2.0/user/config/custom.pod
Date Tue, 20 Sep 2005 22:11:22 GMT
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


Mime
View raw message