perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Devin Teske" <dte...@vicor.com>
Subject Re: Custom INC per-directory
Date Wed, 21 Oct 2009 03:04:52 GMT
Ended up just knocking out the PerlSetEnv LIBDIR in favor of giving 
librequire a new first variable of $r and basing the lib path off of 
$r->filename()

Why $r->filename() you say? Because $r->uri() is before any Alias 
translations with mod_alias.
--
Devin Teske

----- Original Message ----- 
From: "Devin Teske" <dteske@vicor.com>
To: "Brad Van Sickle" <bvs7085@gmail.com>; "Adam Prime" 
<adam.prime@utoronto.ca>
Cc: "Alan Young" <alansyoungiii@gmail.com>; "Michael Peters" 
<mpeters@plusthree.com>; <modperl@perl.apache.org>
Sent: Tuesday, October 20, 2009 4:51 PM
Subject: Re: Custom INC per-directory


> Hehe, it does seem kind of looney, doesn't it?
>
> In a broad scope (see last e-mail which explains the benefits we gain), it 
> is solving a real problem.
>
> For example, which might be efficient enough...
>
> # ...
> my $MOD = SomeMod;
> sub handler()
> {
>    # ...
>    if ( $INC{$MOD} ne $ENV{'LIBDIR'}/$MOD )
>    {
>        delete $INC{$MOD};
>    }
>    require $MOD;
>    # ...
> }
> # ...
>
>
> Might as well just make a new sub to replace require()...
>
> sub librequire() {
>    my ($filename) = @_;
>    if (exists $INC{$filename}) {
>        return 1 if ( $INC{$filename} =~ m#^$ENV{'LIBDIR'}/# );
>    }
>    my ($realfilename,$result);
>    $realfilename = "$ENV{'LIBDIR'}/$filename";
>    if (-f $realfilename) {
>        $INC{$filename} = $realfilename;
>        $result = do $realfilename;
>    }
>    if ($@) {
>        $INC{$filename} = undef;
>        die $@;
>    } elsif (!$result) {
>        delete $INC{$filename};
>        die "$filename did not return true value";
>    } else {
>        return $result;
>    }
> }
>
> That would allow me to simply say "librequire Some::Mod" rather than 
> "require Some::Mod" and have the same effect, allowing us to defeat the 
> cache when necessary, always getting the right module, whether it's 
> provided by cache or not.
> --
> Devin Teske
>
>
> ----- Original Message ----- 
> From: "Brad Van Sickle" <bvs7085@gmail.com>
> To: "Adam Prime" <adam.prime@utoronto.ca>
> Cc: "Alan Young" <alansyoungiii@gmail.com>; "Devin Teske" 
> <dteske@vicor.com>; "Michael Peters" <mpeters@plusthree.com>; 
> <modperl@perl.apache.org>
> Sent: Tuesday, October 20, 2009 4:22 PM
> Subject: Re: Custom INC per-directory
>
>
>>I don't know the specifics of your project so it's quite possible that I'm 
>>missing something, but this all seems like an incredibly bad idea.
>> Sure you can knock some cringe inducing code together and get it to 
>> technically work, but the very fact that you need to resort to these sort 
>> of unorthodox methods should be a hint that you might have something 
>> wrong in your systems or software design.
>> Again, I lack a full perspective here and maybe you have good reasons, 
>> but this sounds like a problem screaming to be solved in conception, not 
>> in implementation.
>>
>>
>>
>>
>> Adam Prime wrote:
>>> Alan Young wrote:
>>>> Wouldn't using the Parent option (
>>>> http://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_ )
>>>> work better for what you're trying to do?
>>>
>>> Parents requires vhosts, which he said he doesn't want to use.
>>>
>>> Adam
>>
>
> 


Mime
View raw message