|
From: Pinglei Z. <zh...@mo...> - 2005-02-15 22:08:00
|
>I second this from Chris about run-time configuration with XORT. I've done
>that/had to do that to get it working for flybase server uses.
Originally set as runtime config, some how see objections and changed to the
ways it is now. Maybe should adopt both ways ?
Pinglei
>>I have one request as far as XORT is concerned. Would it not be possible
>>to allow runtime config rather than install-time config. All this setting
>>of chado variables at Makefile.PL stage doesn't seem quite right. I'm not
>>sure why things have to be set in Constants.pm.
>
>Basically this one needs some config-file lookup code.
>-- Don
>
>package XML::XORT::Util::GeneralUtil::Constants;
>use strict;
>use Cwd;
>use File::Spec;
>
>## dgg here to make this path-independent
>use File::Spec::Functions qw/ catdir catfile /;
>use FindBin qw( $Bin );
>use Cwd qw(abs_path);
>
>use vars qw/$myroot $CONF_DIR %CONSTANT/;
>
>## stuff from installer I don't want
># my %CONSTANT=(DBPORT=>'7302',
># SQLFILE=>'/Users/gilbertd/mailf/04oct/docs/FB_XORT/conf/chado.ddl',
># TMP=>'/bio/biodb/common/perl/XORT2/tmp',
># DBHOST=>'localhost',
># CONF=>'/bio/biodb/common/perl/XORT2/conf',
># DBNAME=>'dmel_chado',
># DBUSER=>'flybase',
># );
>
>sub constants
>{
> $CONF_DIR= confdir();
> # return %CONSTANT if scalar(%CONSTANT);
> return (
> TMP => $ENV{XORT_TMP} || $ENV{TMP} || "/tmp",
> CONF => $CONF_DIR,
> DBNAME => $ENV{CHADO_DB_NAME}|| $ENV{DBNAME}|| 'chado',
> DBPORT => $ENV{CHADO_DB_PORT}|| $ENV{DBPORT}|| 7302,
> DBUSER => $ENV{CHADO_DB_USERNAME}|| $ENV{DBUSER}|| '',
> DBPASSWORD => $ENV{CHADO_DB_PASSWORD}|| $ENV{DBPASSWORD}|| '',
> );
>}
>
>sub confdir
>{
> return $CONF_DIR if($CONF_DIR && -d $CONF_DIR);
> if (defined $ENV{'GMOD_ROOT'} && -d $ENV{'GMOD_ROOT'}) { $myroot=
$ENV{'GMOD_ROOT'}; }
> else { $myroot= abs_path($Bin); }
> $myroot= _updir( $myroot, ["conf"] ); # in case we are not in bin/ folder
> return $ENV{XORT_CONF} if $ENV{XORT_CONF};
> foreach my $d ($myroot, $ENV{XORT}, $ENV{CodeBase}) {
> return "$d/conf" if ($d && -d $d && -d "$d/conf");
> }
> return "./conf";
>}
>
>
>sub _updir
>{
> my ($atdir,$todirs)= @_;
> my $dir= $atdir;
> my $ok= 0;
> my $cod;
> foreach my $td (@$todirs) { $cod= catdir($dir, $td); $ok= (-d $cod); last if
$ok; }
> while (!$ok && length($dir)>2) {
> $dir= "$dir/..";
> $dir=`cd "$dir" && pwd`; chomp($dir);
> foreach my $td (@$todirs) { $cod= catdir($dir, $td); $ok= (-d $cod); last
if $ok; }
> }
> return ($ok) ? $dir : $atdir;
>}
>
>
>BEGIN {
> $CONF_DIR= confdir();
> %CONSTANT= constants();
>}
>#------------------------------------
>
>sub new (){
> my $type=shift;
> my $self={};
> bless $self, $type;
> return $self;
>}
>
>sub get_constant (){
> my $self=shift;
> my $key=shift;
> return $CONSTANT{$key} || $ENV{$key};
>}
>
>sub add_constant(){
> my $self=shift;
> my $key=shift;
> my $value=shift;
> $CONSTANT{$key}=$value;;
>}
>
>1;
>
>
>
>-------------------------------------------------------
>SF email is sponsored by - The IT Product Guide
>Read honest & candid reviews on hundreds of IT Products from real users.
>Discover which products truly live up to the hype. Start reading now.
>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
>_______________________________________________
>Gmod-schema mailing list
>Gmo...@li...
>https://lists.sourceforge.net/lists/listinfo/gmod-schema
|