Apache-Handlers

 view release on metacpan or  search on metacpan

lib/Apache/Handlers.pm  view on Meta::CPAN

=item PerlTypeHandler

=back 4



=head2 Other Methods

=over 4

=item dump

This will dump the current set of code references and return the string.
This uses L<Data::Dumper|Data::Dumper>.

=item reset

This will clear out all previously set code.  This should only be used in
the C<startup.pl> or equivalent so that code doesn't get run twice during a
request (when it should only be run once).  This will also run any RESET
blocks that have been defined.

=item run_phase

Given a list of phases (using the names for the block constructs above),
this will run through the code for that phase, C<die>ing (outside mod_perl)
or logging (if in mod_perl) if there is an error.  For example,

  run_phase( qw: CONTENT LOG CLEANUP : );

will run any code associated with the CONTENT, LOG, and CLEANUP phases.

=back 4


=head1 CAVEATS

Caveats are things that at first glance might be bugs, but end up
potentially useful.  So I am going to make this section into a kind of
cookbook for non-obvious uses for these potential bugs.

=head2 Authentication and Authorization

Be aware that these two phases only run if Apache has reason to believe
they are needed.  This can be a bit handy since the following snippet
should tell you if the authentication phase was run.  Of course, if an
authentication handler runs before this and returns OK, then this may not
run.

  my $authentication_ran : PerlTransHandler(0) PerlAuthenHandler(1);

  LOG {
    if($authentication_ran) {
      # log something special
    }
  };

=head2 Errors

If code causes an error (such that an eval would set $@), then the request
will throw a SERVER_ERROR and write $@ to either STDERR (if not in mod_perl
and there is no C<die> handler, such as the L<Error|Error> module) or to
the Apache error log with a log level of debug.

=head2 C<Use>ing modules

Any of the block constructs or attributes provided by this module that are
used in the body of a module that is brought in via the C<use> keyword will
be considered to take place before the child is spawned.  This means that
any code designated to run during a particular phase will be run at the
appropriate time as if the module had been loaded during the server
startup.

Modules can now rest assured that using a CLEANUP block in their file will
mean that code is run at the end of every request, even if the module was
loaded in the child process and not during server startup.

This is done by looking for code run during the BEGIN phase.

=head1 BUGS

Unlike caveats, bugs are features that are undesirable and/or get in the
way of doing something useful.  I'm sure there are some.  Please let me
know when you find them.

=head2 Security

There is no way (currently) to limit registration of code for later
processing during a particular phase.  Ideas are welcome for how this
should be designed.

=head1 SEE ALSO

L<Apache>,
L<Attribute::Handlers>,
L<Data::Dumper>.

=head1 AUTHOR

James G. Smith <jsmith@cpan.org>

=head1 COPYRIGHT

Copyright (C) 2002 Texas A&M University.  All Rights Reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.



( run in 2.108 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )