Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Apache2::ASP::Base
Base class for ASP engines

Apache2::ASP::Base - Base class for ASP engines



NAME

Apache2::ASP::Base - Base class for ASP engines


SYNOPSIS


  package MyASP;

  

  use strict;

  use base 'Apache2::ASP::Base';

  

  # Use whatever Apache2::* and APR::* modules are necessary:

  

  sub handler : method

  {

    my ($class, $r) = @_;

    

    # We function best as an object:

    my $s = $class->SUPER::new( $ENV{APACHE2_ASP_CONFIG} );

    

    # What Apache2::ASP::Handler is going to handle this request?

    my $handler_class = $s->resolve_request_handler( $r->uri );

    if( $handler_class->isa('Apache2::ASP::UploadHandler') )

    {

      # We use the upload_hook functionality from Apache::Request

      # to process uploads:

      my $upload_hook = sub {

        my ($upload, $data) = @_;

        # Handle upload hook here...

      };

      $s->{q} = Apache2::ASP::CGI->new( $r, $upload_hook );

    }

    else

    {

      # Not an upload - normal CGI functionality will work fine:

      $s->{q} = Apache2::ASP::CGI->new( $r );

    }# end if()

    

    # Get our subref and execute it:

    my $handler = $s->setup_request( $r, $s->{q} );

    my $status = eval { $handler->( ) };

    if( $@ )

    {

      warn "ERROR AFTER CALLING \$handler->( ): $@";

      return $s->_handle_error( $@ );

    }# end if()

    

    # 0 = OK, everything else means errors of some kind:

    return $status;

  }# end handler()

  

  sub _handle_error

  {

    my ($s, $err) = @_;

    

    my $stack = Devel::StackTrace->new;

    warn $stack->as_string;

    $s->response->Clear();

    $s->global_asa->can('Script_OnError')->( $stack );

    

    return 500;

  }# end _handle_error()


DESCRIPTION


METHODS

new( $config )

Returns a new Apache2::ASP::Base object using the Apache2::ASP::Config object passed in as $config.

setup_request( $r )

Creates a new request instance, based on the information about the request gleaned from $r - an the Apache2::RequestRec manpage object (or something that behaves like one anyway).

Returns a subroutine reference.

Execute like:


  my $ref = $asp->setup_request( $r );

  

  # A normal request:

  $ref->( 0 );

  # or

  $ref->( );

  

  # A subrequest (i.e. as in the case of an include):

  $ref->( 1 );

config( )

Returns the current the Apache2::ASP::Config manpage object.

r( )

Returns the the Apache2::RequestRec manpage object.

q( )

Returns the the Apache2::ASP::CGI manpage object.

session( )

Returns the current the Apache2::ASP::SessionStateManager manpage object.

request( )

Returns the current the Apache2::ASP::Request manpage object.

response( )

Returns the current the Apache2::ASP::Response manpage object.

server( )

Returns the current the Apache2::ASP::Server manpage object.

application( )

Returns the current the Apache2::ASP::Application manpage object.

global_asa( )

Returns the the Apache2::ASP::GlobalASA manpage object.

resolve_request_handler( $uri )

Returns the classname of the the Apache2::ASP::Handler manpage subclass that will process the current HTTP request.


BUGS

It's possible that some bugs have found their way into this release.

Use RT http://rt.cpan.org/NoAuth/Bugs.html to submit bug reports.


HOMEPAGE

Please visit the Apache2::ASP homepage at http://apache2-asp.no-ip.org/ to see examples of Apache2::ASP in action.


AUTHOR

John Drago mailto:jdrago_999@yahoo.com


COPYRIGHT AND LICENSE

Copyright 2007 John Drago, All rights reserved.

This software is free software. It may be used and distributed under the same terms as Perl itself.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy