OpenPlugin::Request::Apache - Apache driver for the OpenPlugin::Param plugin


OpenPlugin documentation Contained in the OpenPlugin distribution.

Index


Code Index:

NAME

Top

OpenPlugin::Request::Apache - Apache driver for the OpenPlugin::Param plugin

PARAMETERS

Top

In order to use the Apache driver, you must pass in an Apache or Apache::Request object when creating a new OpenPlugin object. For example:

 my $r = shift;
 my $OP = OpenPlugin->new( request => { apache => $r } );

After the plugin is initialized, the Apache::Request object is accessible to you using:

 $apache_req = $OP->request->object();

CONFIG OPTIONS

Top

* driver

Apache

BUGS

Top

None known.

TO DO

Top

Nothing known.

SEE ALSO

Top

OpenPlugin OpenPlugin::Param Apache (Apache) Apache::Request

COPYRIGHT

Top

AUTHORS

Top

Eric Andreychek <eric@openthought.net>


OpenPlugin documentation Contained in the OpenPlugin distribution.

package OpenPlugin::Request::Apache;

# $Id: Apache.pm,v 1.5 2003/04/03 01:51:25 andreychek Exp $

use strict;
use OpenPlugin::Param();
use base   qw( OpenPlugin::Param );
use Apache::Request();


$OpenPlugin::Request::Apache::VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);

sub init {
    my ( $self, $args ) = @_;

    # This is here for now because when compiling this module at Apache startup
    # time, we don't have an Apache::Request object yet.  We should find a
    # better way to do this though.
    return $self unless ( $args->{'apache'} );

    # Make sure we have an Apache::Request object
    unless ( $self->state->{'apache'} ) {

        # If passed in an Apache::Request object, use it
        if( ref $args->{'apache'} eq "Apache::Request" ) {
            $self->state->{'apache'} = $args->{'apache'};
        }
        # If passed in an Apache object, we can work with that too
        elsif( ref $args->{'apache'} eq "Apache" ) {
            $self->state->{'apache'} =
                Apache::Request->new( $args->{'apache'} );
        }
        else {
            $self->OP->exception->throw("When using the Apache driver, you ",
                    "must pass in an Apache or Apache::Request object!");
        }
    }

    # Set the uri
    $self->state->{'uri'} = $self->state->{'apache'}->uri;

    return $self;
}

sub object { my $self = shift; return $self->state->{apache}; }
sub uri    { my $self = shift; return $self->state->{uri};    }

1;

__END__