You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Issac Goldstand <ma...@beamartyr.net> on 2001/12/18 15:15:24 UTC

using Apache::ReadConfig to configure from perl scripts

Hi all...  I'm trying to put the finishing touches on 
Apache::UploadMeter, but am running into a minor problem.  Due to the 
complexity of the configuration, I'm trying to use the 
Apache::ReadConfig namespace from mod_perl_start.pl to dynamically 
configure the upload-meter (by setting some variables in the 
Apache::UploadMeter namespace and then calling a configure() routine).

Enclosed is the configure() subroutine.  It runs fine, but doesn't seem 
to be tying the handlers properly.  Any advice would be helpful.  Also, 
if anyone know how I could dynamicly add handlers to the stack directly 
from the Apache::ReadConfig namespace without knowing in advance what 
other handlers are enabled for a given Location, that would be helpful...

  Issac

sub configure()
{
    my $namespace=__PACKAGE__;
    my 
($UploadScript,$UploadMeter,$UploadForm)=(_conf("UploadScript"),_conf("UploadMeter"),_conf("UploadForm"));
    warn "Config $UploadScript - $UploadMeter - $UploadForm - in 
namespace $namespace" if (_conf("DEBUG")>1);
    package Apache::ReadConfig;
    no strict;
    $Location{$UploadScript} = {
    SetHandler => 'perl-script',
    Options => '+ExecCGI',
    #PerlHeaderParserHandler => $namespace."::u_handler",
    #PerlFixupHandler => $namespace."::ufu_handler",
    PerlHeaderParserHandler => $namespace."::jit_upload",
    };
    $Location{$UploadMeter} = {
    SetHandler => 'perl-script',
    Options => '+ExecCGI',
    #PerlHandler => $namespace."::um_handler",
    PerlHeaderParserHandler => $namespace."::jit_meter",
    };
    $Location{$UploadForm} = {
    Options => '+ExecCGI',
    SetHandler => 'perl-script',
    #PerlFixupHandler => $namespace."::s_h",
    #PerlTransHandler => $namespace."::uf_handler",
    PerlHandler => $namespace,
    PerlInitHandler => $namespace."::s_h",
    };
    return 1;
}

sub _conf($)
{
    my $arg=shift;
    warn ("Extracting $arg...".eval("\$".__PACKAGE__."::".$arg)) if 
(eval("\$".__PACKAGE__."::DEBUG > 1"));
    return eval("\$".__PACKAGE__."::".$arg);
}



-- 
Internet is a wonderful mechanism for making a fool of
yourself in front of a very large audience.
  --Anonymous

Moving the mouse won't get you into trouble...  Clicking it might.
  --Anonymous

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B






Re: using Apache::ReadConfig to configure from perl scripts

Posted by Issac Goldstand <ma...@beamartyr.net>.
Well, I'm getting some of the stuff to work... Just not all three 
Locations and I can't figure out what keeps breaking.  It's really 
weird...  When I had the first two handlers set to PerlInitHandler and 
the third to PostReadRequestHandler (Which ought not work in a Location) 
only the third works, yet when I try setting them all to 
PostReadRequestHandler, NONE of them work...  I'm really quite lost and 
would appreciate any help anyone could offer about setting perl handlers 
in <Perl> sections in general

  Issac

Geoffrey Young wrote:

>Issac Goldstand wrote:
>
>>Hi all...  I'm trying to put the finishing touches on
>>Apache::UploadMeter, but am running into a minor problem.  Due to the
>>complexity of the configuration, I'm trying to use the
>>Apache::ReadConfig namespace from mod_perl_start.pl to dynamically
>>configure the upload-meter (by setting some variables in the
>>Apache::UploadMeter namespace and then calling a configure() routine).
>>
>>Enclosed is the configure() subroutine.  It runs fine, but doesn't seem
>>to be tying the handlers properly.  Any advice would be helpful.  Also,
>>if anyone know how I could dynamicly add handlers to the stack directly
>>from the Apache::ReadConfig namespace without knowing in advance what
>>other handlers are enabled for a given Location, that would be helpful...
>>
>
>I tried something similar in this (highly experimental and unfinished)
>module
>
>http://www.modperlcookbook.org/~geoff/modules/Apache-ReverseLocation-0.01.tar.gz
>
>maybe looking that module over would be of some help...
>
>had I the inclination, I would use the qr// operator to properly fix
>the Alias bit, and do something better about the vhost problem, and...
>at any rate, overriding <Location> and friends is a cool way to know
>what <Location>s are in your httpd.conf...
>
>HTH
>
>--Geoff
>


-- 
Internet is a wonderful mechanism for making a fool of
yourself in front of a very large audience.
  --Anonymous

Moving the mouse won't get you into trouble...  Clicking it might.
  --Anonymous

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B







Re: using Apache::ReadConfig to configure from perl scripts

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Issac Goldstand wrote:
> 
> Hi all...  I'm trying to put the finishing touches on
> Apache::UploadMeter, but am running into a minor problem.  Due to the
> complexity of the configuration, I'm trying to use the
> Apache::ReadConfig namespace from mod_perl_start.pl to dynamically
> configure the upload-meter (by setting some variables in the
> Apache::UploadMeter namespace and then calling a configure() routine).
> 
> Enclosed is the configure() subroutine.  It runs fine, but doesn't seem
> to be tying the handlers properly.  Any advice would be helpful.  Also,
> if anyone know how I could dynamicly add handlers to the stack directly
> from the Apache::ReadConfig namespace without knowing in advance what
> other handlers are enabled for a given Location, that would be helpful...
> 

I tried something similar in this (highly experimental and unfinished)
module

http://www.modperlcookbook.org/~geoff/modules/Apache-ReverseLocation-0.01.tar.gz

maybe looking that module over would be of some help...

had I the inclination, I would use the qr// operator to properly fix
the Alias bit, and do something better about the vhost problem, and...
at any rate, overriding <Location> and friends is a cool way to know
what <Location>s are in your httpd.conf...

HTH

--Geoff