Apache-SessionX
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
print "\nChecking configuration...\n" ;
store:
foreach $store (sort keys %Store)
{
$data = $Store{$store} ;
$info = $data -> {param}{Info} ||= $store ;
if ($data -> {'require'})
{
foreach $require (@{$data -> {'require'}})
{
eval "require $require" ;
if ($@)
{
print "Storage '$info' is unavailable because $require is not installed on your system\n" ;
next store ;
}
}
}
push @avail, $store ;
}
print "\nThe following ways to store session are available on your system:\n" ;
foreach $store (@avail)
{
$data = $Store{$store} ;
$info = $data -> {param}{Info} ;
printf (" - %-20s: %s\n", $store, $info) ;
}
eval { require 'SessionX/Config.pm' ; } ;
if (!keys %Apache::SessionX::Config::param)
{
eval { require Apache::SessionX::Config ; } ;
}
if (keys %Apache::SessionX::Config::param)
{
%param = %Apache::SessionX::Config::param ;
@conf = @Apache::SessionX::Config::confs ;
$input = GetYesNo ("Found previous configuration. Modify it", 0) ;
}
else
{
%param = map { $_ => {} } @avail ;
$input = 1 ;
}
if ($input)
{
@conf = () ;
print "\n" ;
print "You can now specify the configuration parameters for every storage.\n" ;
print "Apache::SessionX uses this for testing your system and stores it for later\n" ;
print "use in your application. You can override these default parameters anytime\n" ;
print "at runtime. You can change them by rerunning Makefile.PL.\n" ;
print "\nIf you don't plan to use different storages for session, \nonly say Yes to the one storage you want to use.\n" ;
foreach $store (@avail)
{
print "\n" ;
$data = $Store{$store} ;
$info = $data -> {param}{Info} ;
if (GetYesNo("Would you like to configure $info ($store)", $param{$store}?1:0))
{
push @conf, $store ;
$param{$store} = { %{$data->{param}} } if (!keys %{$param{$store}}) ;
while (($param, $value) = each (%{$data->{param}}))
{
if ($value eq '?')
{
$value = GetString ($param, $param{$store}{$param} eq '?'?'':$param{$store}{$param}) ;
$param{$store}{$param} = $value ;
}
}
$param{$store}{'Store'} ||= $store ;
$param{$store}{'Serialize'} ||= 'Storeable' ;
$param{$store}{'Lock'} ||= 'Semaphore' ;
$param{$store}{'Generate'} ||= 'MD5' ;
}
}
print "\n" ;
$i = 1 ;
foreach $store (@conf)
{
$data = $Store{$store} ;
$info = $data -> {param}{Info} ;
print " $i: $info ($store)\n" ;
$def = $i if ($Apache::SessionX::Config::default eq $store) ;
$i++ ;
}
$i-- ;
if ($i == 1)
{
$default = 0 ;
}
else
{
$default = GetString ("Which of the above should be your default store (1-$i)", $def || '') ;
$default-- ;
}
}
print "Using $conf[$default] as default\n" ;
open FH, ">SessionX/Config.pm" or die "Cannot open SessionX/Config.pm for writing ($!)" ;
print FH qq{
#
# Apache::SessionX configuration
#
# Autogenerated by Makefile.PL, do not edit!
#
package Apache::SessionX::Config ;
( run in 0.751 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )