You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Scott Wessels <sw...@usgn.net> on 2005/10/05 01:33:00 UTC
PerlSections and Tie::DxHash issue
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.
--- PerlSections.pm 2005-10-04 15:42:00.000000000 -0700
+++ PerlSections.pm.no_sort_keys 2005-10-04 15:41:34.000000000 -0700
@@ -129,7 +129,7 @@
sub dump_hash {
my($self, $name, $hash) = @_;
- for my $entry (sort keys %{ $hash || {} }) {
+ for my $entry (keys %{ $hash || {} }) {
my $item = $hash->{$entry};
my $type = ref($item);
@@ -149,7 +149,7 @@
$self->add_config("<$name $loc>\n");
- for my $entry (sort keys %{ $hash || {} }) {
+ for my $entry (keys %{ $hash || {} }) {
$self->dump_entry($entry, $hash->{$entry});
}
--
Scott Wessels
CTO
US Global Net
Cell: (480) 330 4084
Office: (602) 745 2498
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: PerlSections and Tie::DxHash issue
Posted by Scott Wessels <sw...@usgn.net>.
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
Re: PerlSections and Tie::DxHash issue
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>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.
actually, in mp1 we used Tie::IxHash behind the scenes if it was present,
but that was really just part of a whole solution. Tie::DxHash solves a
related but different problem than Tie::IxHash. you can read all about in
in the archives or in recipe 2.17 in the mp cookbook or in the Tie::DxHash
manpage (IIRC).
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: PerlSections and Tie::DxHash issue
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
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
--
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Re: PerlSections and Tie::DxHash issue
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
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.
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.
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: PerlSections and Tie::DxHash issue
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Scott Wessels wrote:
> --- PerlSections.pm 2005-10-04 15:42:00.000000000 -0700
> +++ PerlSections.pm.no_sort_keys 2005-10-04 15:41:34.000000000 -0700
> @@ -129,7 +129,7 @@
> sub dump_hash {
> my($self, $name, $hash) = @_;
>
> - for my $entry (sort keys %{ $hash || {} }) {
> + for my $entry (keys %{ $hash || {} }) {
> my $item = $hash->{$entry};
> my $type = ref($item);
>
> @@ -149,7 +149,7 @@
>
> $self->add_config("<$name $loc>\n");
>
> - for my $entry (sort keys %{ $hash || {} }) {
> + for my $entry (keys %{ $hash || {} }) {
> $self->dump_entry($entry, $hash->{$entry});
> }
Geof, I beat you to it :).
Comitted Thanks!
--
END
------------------------------------------------------------
What doesn't kill us can only make us stronger.
Nothing is impossible.
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
http://www.liquidityservicesinc.com
http://www.liquidation.com
http://www.uksurplus.com
http://www.govliquidation.com
http://www.gowholesale.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org