From 1150528b8a5a3f4686f82e796c500471fb6ebe1a Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 16 Apr 2010 20:13:42 -0500 Subject: [PATCH] delete WebGUI::Session::Os --- lib/WebGUI/Session.pm | 22 +--------- lib/WebGUI/Session/Os.pm | 88 ---------------------------------------- sbin/fileImport.pl | 2 +- sbin/testEnvironment.pl | 2 +- t/Session/Os.t | 52 ------------------------ 5 files changed, 4 insertions(+), 162 deletions(-) delete mode 100644 lib/WebGUI/Session/Os.pm delete mode 100644 t/Session/Os.t diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 3ceca9acf..0035ade0b 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -68,7 +68,6 @@ B It is important to distinguish the difference between a WebGUI session $session->icon $session->id $session->output - $session->os $session->privilege $session->request $session->response @@ -145,7 +144,7 @@ sub close { # Kill circular references. The literal list is so that the order # can be explicitly shuffled as necessary. - foreach my $key (qw/_asset _datetime _icon _slave _db _env _form _http _id _output _os _privilege _scratch _setting _stow _style _url _user _var _cache _errorHandler _response _request/) { + foreach my $key (qw/_asset _datetime _icon _slave _db _env _form _http _id _output _privilege _scratch _setting _stow _style _url _user _var _cache _errorHandler _response _request/) { delete $self->{$key}; } } @@ -454,7 +453,7 @@ Uses simple session vars. See WebGUI::Session::Var::new() for more details. sub open { my ($class, $c, $env, $sessionId, $noFuss) = @_; my $config = ref $c ? $c : WebGUI::Config->new($c); - my $self = {_config=>$config }; # TODO - if we store reference here, should we weaken WebGUI->config? + my $self = { _config => $config }; bless $self, $class; if ($env) { @@ -493,23 +492,6 @@ sub output { } -#------------------------------------------------------------------- - -=head2 os ( ) - -Returns a WebGUI::Session::Os object. - -=cut - -sub os { - my $self = shift; - unless (exists $self->{_os}) { - $self->{_os} = WebGUI::Session::Os->new(); - } - return $self->{_os}; -} - - #------------------------------------------------------------------- =head2 privilege ( ) diff --git a/lib/WebGUI/Session/Os.pm b/lib/WebGUI/Session/Os.pm deleted file mode 100644 index 80ebd7c10..000000000 --- a/lib/WebGUI/Session/Os.pm +++ /dev/null @@ -1,88 +0,0 @@ -package WebGUI::Session::Os; - -=head1 LEGAL - - ------------------------------------------------------------------- - WebGUI is Copyright 2001-2009 Plain Black Corporation. - ------------------------------------------------------------------- - Please read the legal notices (docs/legal.txt) and the license - (docs/license.txt) that came with this distribution before using - this software. - ------------------------------------------------------------------- - http://www.plainblack.com info@plainblack.com - ------------------------------------------------------------------- - -=cut - -use strict; - -=head1 NAME - -Package WebGUI::Session::Os - -=head1 DESCRIPTION - -This package allows you to reference environment variables. - -=head1 SYNOPSIS - -$os = WebGUI::Session::Os->new; - -$value = $os->get('name'); - -=head1 METHODS - -These methods are available from this package: - -=cut - -#------------------------------------------------------------------- - -=head2 get( varName ) - -Retrieves the current value of an operating system variable. - -=head3 varName - -The name of the variable. - -=head4 name - -The name of the operating system as reported by perl. - -=head4 type - -Will either be "Windowsish" or "Linuxish", which is often more useful than name because the differences between various flavors of Unix, Linux, and BSD are usually not that significant. - -=cut - -sub get { - my $self = shift; - my $var = shift; - return $self->{_os}{$var}; -} - - -#------------------------------------------------------------------- - -=head2 new ( ) - -Constructor. Returns an OS object. - -=cut - -sub new { - my $class = shift; - my $self = {}; - $self->{_os}{name} = $^O; - if ($self->{_os}{name} =~ /MSWin32/i || $self->{_os}{name} =~ /^Win/i) { - $self->{_os}{type} = "Windowsish"; - } else { - $self->{_os}{type} = "Linuxish"; - } - bless $self, $class; -} - - - -1; diff --git a/sbin/fileImport.pl b/sbin/fileImport.pl index e71dfc5ae..3c00104be 100755 --- a/sbin/fileImport.pl +++ b/sbin/fileImport.pl @@ -202,7 +202,7 @@ sub setPrivilege { my $path = shift; print "\t\tSetting filesystem privilege. " unless ($quiet); - if ($session->os->get("type") eq "Linuxish") { + if ($^O ne 'MSWin32') { unless (system("chown -R ".$webUser." ". $path)) { print "Privileges set.\n" unless ($quiet); } diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index c6b06b009..97d31765d 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -26,7 +26,7 @@ use Pod::Usage; use Cwd (); -my ($os, $prereq, $dbi, $dbDrivers, $simpleReport, $help, $noprompt); +my ($prereq, $dbi, $dbDrivers, $simpleReport, $help, $noprompt); GetOptions( 'noprompt' => \$noprompt, diff --git a/t/Session/Os.t b/t/Session/Os.t deleted file mode 100644 index 9fd1f7bfb..000000000 --- a/t/Session/Os.t +++ /dev/null @@ -1,52 +0,0 @@ -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2009 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -use FindBin; -use strict; -use lib "$FindBin::Bin/../lib"; - -use WebGUI::Test; -use WebGUI::Session; -use WebGUI::Session::Os; - -my @testSets = ( - { - os => 'Win', - type => 'Windowsish', - }, - { - os => 'win32', - type => 'Windowsish', - }, - { - os => 'MSWin32', - type => 'Windowsish', - }, - { - os => 'Amiga OS', - type => 'Linuxish', - }, -); - -use Test::More; - -my $numTests = 2 * scalar @testSets; - -plan tests => $numTests; - -my $session = WebGUI::Test->session; - -foreach my $test (@testSets) { - local $^O = $test->{os}; - my $os = WebGUI::Session::Os->new($session); - is($os->get('name'), $test->{os}, "$test->{os}: name set"); - is($os->get('type'), $test->{type}, "$test->{os}: type set"); -} -