perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Wessels <swess...@usgn.net>
Subject Re: PerlSections and Tie::DxHash issue
Date Thu, 06 Oct 2005 21:59:21 GMT
Philippe M. Chiasson wrote:

>Geoffrey Young wrote:
>  
>
>>Scott Wessels wrote:
>>
>>    
>>
>>>In attempting to implement a complete PerlSections apache configuration,
>>>I ran into a problem when trying to use multiple
>>>RewriteCond/RewriteRules and Tie::DxHash
>>>(http://search.cpan.org/~kruscoe/Tie-DxHash-0.93/lib/Tie/DxHash.pm) in a
>>>$VirtualHost. When using Apache2::PerlSections->dump, the configuration
>>>would print out in the correct order, but when the configuration was
>>>passed off to Apache the ordering was lost. The following patches
>>>resolves the issue.
>>>      
>>>
>>excellent.
>>    
>>
>
>Bug indeed!
>
>So, just curious, are you using Tie::DxHash to tie %VirtualHost yourself ?
>Because in mp1 land, various magical <Perl> vars were tied like that behind
>the scenes. It wasn't really ported over to 2.0 and maybe it just should.
>
>  
>
>>we're in code-freeze at the moment, giving 2.0.2 a chance to marinate.
>>after that I'll commit it unless someone beats me to it.
>>    
>>
>
>+1
>
>  
>


Actually, I'm using it for any of the % sections that have multiple keys 
of the same name. If there aren't multiple keys of the same name, then I 
just treate it like a regular hash.

I'd suggest not having hidden Tie magic. Hashes should behave like 
hashes unless the user specifically ties the hash. Just make a note or 
an example in the docs.


###################

use Tie::DxHash;
sub gen_conf {
    my %conf;
    tie %conf, 'Tie::DxHash';

    %conf = @_;
    return \%conf;
}

#....

$Directory{'/vol[1-9]/*/custom'} = gen_conf(
    Options => '+ExecCGI',
    RewriteEngine => 'On',
    RewriteCond => '%{REQUEST_URI} /custom/(.+)$',
    RewriteCond => '%{DOCUMENT_ROOT}/custom/%1 !-f',
    RewriteRule => '^.+$ /cgi/%1 [L]',
);

$Directory{'/var/opm/cvsweb'} = {
   Options => '+ExecCGI',
   AuthType => 'Basic',
   AuthName => '"USGN CVS Repository"',
   AuthUserFile => '/var/opm/cvsweb/passwd',
   Require => 'user scottw',
};

#....

push @{ $VirtualHost{'69.28.173.71' . ':' . $__Port} }, gen_conf(
    ServerName => 'usglobal.net',
    DocumentRoot => '/vol1/usglobal',
    ErrorLog => '/var/log/httpd/usglobal.error.log',

    RewriteCond => '%{REQUEST_METHOD} ^(TRACE|TRACK)',
    RewriteRule => '.* - [F]',

    # set the BASE dir and default SITENAME
    RewriteRule => '^ - 
[E=BASE:/vol1/,E=SITENAME:usglobal,E=D_SITENAME:usglobal]',

    # match host prefix, eg. (wildoats).usgn.org
    #RewriteCond => '%{HTTP_HOST} ^([^\.]+)\.?',
    RewriteCond => '%{HTTP_HOST} ^([^\.]+)',

    # skip ip based HTTP_HOST
    RewriteCond => '%1 !^[0-9]+$',

    # set SITENAME ENV variable
    RewriteRule => '^ - [E=SITENAME:%1]',

    # if SITENAME wasn't found default it to D_SITENAME
    RewriteCond => '%{ENV:SITENAME} ^$ [OR]',
    RewriteCond => '%{ENV:SITENAME} ^www$',
    RewriteRule => '^ - [E=SITENAME:%{ENV:D_SITENAME}]',


    # set DOCROOT ENV variable
    RewriteRule => '^ - [E=DOCROOT:%{ENV:BASE}%{ENV:SITENAME}]',
);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message