package Apache2::ASP::Config; use strict; use warnings 'all'; use Carp 'confess'; use base 'Apache2::ASP::ConfigNode'; #============================================================================== sub new { my ($class, $ref, $root) = @_; my $s = $class->SUPER::new( $ref ); $s->init_server_root( $root ); $s->_init_inc(); foreach my $var ( $s->system->env_vars ) { while( my ($key,$val) = each(%$var) ) { $ENV{$key} = $val; }# end while() }# end foreach() map { $s->load_class( $_ ) } $s->system->load_modules; return $s; }# end new() #============================================================================== sub _init_inc { my $s = shift; my %saw = map { $_ => 1 } @INC; push @INC, grep { ! $saw{$_}++ } ( $s->system->libs, $s->web->handler_root ); }# end _init_inc() #============================================================================== sub init_server_root { my ($s, $root) = @_; no warnings 'uninitialized'; foreach( @{ $s->{system}->{libs}->{lib} } ) { $_ =~ s/\@ServerRoot\@/$root/; }# end foreach() foreach( @{ $s->{system}->{settings}->{setting} } ) { $_->{value} =~ s/\@ServerRoot\@/$root/; }# end foreach() foreach my $key (qw/ application handler media_manager_upload www page_cache /) { $s->{web}->{"$key\_root"} =~ s/\@ServerRoot\@/$root/; }# end foreach() }# end init_server_root() #============================================================================== sub load_class { my ($s, $class) = @_; (my $file = "$class.pm") =~ s/::/\//g; eval { require $file unless $INC{$file}; 1 } or confess "Cannot load $class: $@"; }# end load_class() sub DESTROY { my $s = shift; undef(%$s); } 1;# return true: =pod =head1 NAME Apache2::ASP::Config - Central configuration for Apache2::ASP =head1 SYNOPSIS # Settings: $Config->system->settings->some_setting; $Config->system->settings->another_setting; # Error-handling: $Config->errors->error_handler; $Config->errors->mail_errors_to; $Config->errors->mail_errors_from; $Config->errors->smtp_server; # Web: $Config->web->application_name; $Config->web->application_root; $Config->web->www_root; $Config->web->handler_root; $Config->web->media_manager_upload_root; $Config->web->page_cache_root; # Data Connections: foreach my $conn ( map { $Config->data_connections->$_ } qw/ session application main / ) { my $dbh = DBI->connect( $conn->dsn, $conn->username, $conn->password ); }# end foreach() =head1 XML Config File Apache2::ASP keeps all of its configuration inside of C Here is an example: @ServerRoot@/lib DBI myvar value myvar2 value2 mysetting value mysetting2 value2 My::ErrorHandler jdrago_999@yahoo.com root@localhost localhost DefaultApp @ServerRoot@ @ServerRoot@/handlers @ServerRoot@/MEDIA @ServerRoot@/htdocs @ServerRoot@/PAGE_CACHE Apache2::ASP::SessionStateManager::SQLite session-id DBI:SQLite:dbname=/tmp/apache2_asp_applications 30 Apache2::ASP::ApplicationStateManager::SQLite DBI:SQLite:dbname=/tmp/apache2_asp_applications
DBI:SQLite:dbname=/tmp/apache2_asp_applications
=head1 DESCRIPTION =head1 PUBLIC PROPERTIES =head1 PUBLIC METHODS =head1 BUGS It's possible that some bugs have found their way into this release. Use RT L to submit bug reports. =head1 HOMEPAGE Please visit the Apache2::ASP homepage at L to see examples of Apache2::ASP in action. =head1 AUTHOR John Drago =head1 COPYRIGHT Copyright 2008 John Drago. All rights reserved. =head1 LICENSE This software is Free software and is licensed under the same terms as perl itself. =cut