delete WebGUI::Session::Os
This commit is contained in:
parent
7ff307cabe
commit
1150528b8a
5 changed files with 4 additions and 162 deletions
|
|
@ -68,7 +68,6 @@ B<NOTE:> It is important to distinguish the difference between a WebGUI session
|
||||||
$session->icon
|
$session->icon
|
||||||
$session->id
|
$session->id
|
||||||
$session->output
|
$session->output
|
||||||
$session->os
|
|
||||||
$session->privilege
|
$session->privilege
|
||||||
$session->request
|
$session->request
|
||||||
$session->response
|
$session->response
|
||||||
|
|
@ -145,7 +144,7 @@ sub close {
|
||||||
|
|
||||||
# Kill circular references. The literal list is so that the order
|
# Kill circular references. The literal list is so that the order
|
||||||
# can be explicitly shuffled as necessary.
|
# 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};
|
delete $self->{$key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -454,7 +453,7 @@ Uses simple session vars. See WebGUI::Session::Var::new() for more details.
|
||||||
sub open {
|
sub open {
|
||||||
my ($class, $c, $env, $sessionId, $noFuss) = @_;
|
my ($class, $c, $env, $sessionId, $noFuss) = @_;
|
||||||
my $config = ref $c ? $c : WebGUI::Config->new($c);
|
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;
|
bless $self, $class;
|
||||||
|
|
||||||
if ($env) {
|
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 ( )
|
=head2 privilege ( )
|
||||||
|
|
|
||||||
|
|
@ -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;
|
|
||||||
|
|
@ -202,7 +202,7 @@ sub setPrivilege {
|
||||||
my $path = shift;
|
my $path = shift;
|
||||||
print "\t\tSetting filesystem privilege. " unless ($quiet);
|
print "\t\tSetting filesystem privilege. " unless ($quiet);
|
||||||
|
|
||||||
if ($session->os->get("type") eq "Linuxish") {
|
if ($^O ne 'MSWin32') {
|
||||||
unless (system("chown -R ".$webUser." ". $path)) {
|
unless (system("chown -R ".$webUser." ". $path)) {
|
||||||
print "Privileges set.\n" unless ($quiet);
|
print "Privileges set.\n" unless ($quiet);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use Pod::Usage;
|
||||||
use Cwd ();
|
use Cwd ();
|
||||||
|
|
||||||
|
|
||||||
my ($os, $prereq, $dbi, $dbDrivers, $simpleReport, $help, $noprompt);
|
my ($prereq, $dbi, $dbDrivers, $simpleReport, $help, $noprompt);
|
||||||
|
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'noprompt' => \$noprompt,
|
'noprompt' => \$noprompt,
|
||||||
|
|
|
||||||
|
|
@ -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");
|
|
||||||
}
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue