From: short <> Date: Sun, 25 Sep 2005 07:36:18 +0000 (+0000) Subject: Fixed blessing of: $W X-Git-Url: http://git.jankratochvil.net/?p=MyWeb.git;a=commitdiff_plain;h=5d886f3c5fbabcadbaa646db7f6c636dbebec218 Fixed blessing of: $W Fixed/implemented lazy-evaluation of: $W->{"have_style"} Isolated: &footer_packages_used_comments --- diff --git a/Web.pm b/Web.pm index d2878f6..9aafbab 100644 --- a/Web.pm +++ b/Web.pm @@ -145,8 +145,8 @@ my($class,%args)=@_; # $W={} can get somehow created very easily. cluck "W not empty:\n".Dumper($W) if keys(%$W); - $W=bless My::Hash->new({}),$class; - $W=My::Hash->new($W,"My::Hash::Sub","My::Hash::Push"); + $W=My::Hash->new({},"My::Hash::Sub","My::Hash::Push"); + bless $W,$class; %$W=( "__PACKAGE__"=>scalar(caller()), %WebConfig, @@ -260,7 +260,10 @@ my($class,%args)=@_; }; if (!defined $W->{"have_style"}) { - $W->{"have_style"}=(!$W->{"browser"}->netscape() || ($W->{"browser"}->major() && $W->{"browser"}->major()>4) ? 1 : 0); + $W->{"have_style"}=sub { + # Lazy-evaluation, we may not need the "User-Agent" header at all. + return our $r||=(!$W->{"browser"}->netscape() || ($W->{"browser"}->major() && $W->{"browser"}->major()>4) ? 1 : 0); + }; } $W->{"have_js"}=($W->{"args"}{"have_js"} ? 1 : 0); @@ -513,6 +516,17 @@ my($msg)=@_; exit; } +sub footer_packages_used_comments() +{ + my $packages_used=$packages_used_array{$W->{"__PACKAGE__"}}; + for my $package (@$packages_used) { + my $cvs_id=(eval('$'.$package."::CVS_ID") +# || $package # debug + ); + Wprint ''."\n" if $cvs_id; + } +} + sub footer() { cluck 'Explicit &footer call is deprecated, !_exit_dne' if !$W->{"_exit_done"}; @@ -568,12 +582,7 @@ sub footer() Wprint "

\n"; } - for my $package (@$packages_used) { - my $cvs_id=(eval('$'.$package."::CVS_ID") -# || $package # debug - ); - Wprint ''."\n" if $cvs_id; - } + packages_used_comments(); do { Wprint $_ if $_; } for $W->{"footing"};