| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | package Apache2::ASP::Config; | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 24 |  |  | 24 |  | 96 | use strict; | 
|  | 24 |  |  |  |  | 103 |  | 
|  | 24 |  |  |  |  | 820 |  | 
| 5 | 24 |  |  | 24 |  | 97 | use warnings 'all'; | 
|  | 24 |  |  |  |  | 26 |  | 
|  | 24 |  |  |  |  | 770 |  | 
| 6 | 24 |  |  | 24 |  | 95 | use Carp 'confess'; | 
|  | 24 |  |  |  |  | 27 |  | 
|  | 24 |  |  |  |  | 1072 |  | 
| 7 | 24 |  |  | 24 |  | 109 | use base 'Apache2::ASP::ConfigNode'; | 
|  | 24 |  |  |  |  | 35 |  | 
|  | 24 |  |  |  |  | 9853 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | #============================================================================== | 
| 11 |  |  |  |  |  |  | sub new | 
| 12 |  |  |  |  |  |  | { | 
| 13 | 0 |  |  | 0 | 0 |  | my ($class, $ref, $root) = @_; | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 0 |  |  |  |  |  | my $s = $class->SUPER::new( $ref ); | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 0 |  |  |  |  |  | $s->init_server_root( $root ); | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 0 |  |  |  |  |  | $s->_init_inc(); | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 0 |  |  |  |  |  | foreach my $var ( $s->system->env_vars ) | 
| 22 |  |  |  |  |  |  | { | 
| 23 | 0 |  |  |  |  |  | while( my ($key,$val) = each(%$var) ) | 
| 24 |  |  |  |  |  |  | { | 
| 25 | 0 |  |  |  |  |  | $ENV{$key} = $val; | 
| 26 |  |  |  |  |  |  | }# end while() | 
| 27 |  |  |  |  |  |  | }# end foreach() | 
| 28 |  |  |  |  |  |  |  | 
| 29 | 0 |  |  |  |  |  | map { $s->load_class( $_ ) } $s->system->load_modules; | 
|  | 0 |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 0 |  |  |  |  |  | return $s; | 
| 32 |  |  |  |  |  |  | }# end new() | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | #============================================================================== | 
| 36 |  |  |  |  |  |  | sub _init_inc | 
| 37 |  |  |  |  |  |  | { | 
| 38 | 0 |  |  | 0 |  |  | my $s = shift; | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 0 |  |  |  |  |  | my %saw = map { $_ => 1 } @INC; | 
|  | 0 |  |  |  |  |  |  | 
| 41 | 0 |  |  |  |  |  | push @INC, grep { ! $saw{$_}++ } ( $s->system->libs, $s->web->handler_root ); | 
|  | 0 |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | }# end _init_inc() | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | #============================================================================== | 
| 46 |  |  |  |  |  |  | sub init_server_root | 
| 47 |  |  |  |  |  |  | { | 
| 48 | 0 |  |  | 0 | 0 |  | my ($s, $root) = @_; | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 24 |  |  | 24 |  | 137 | no warnings 'uninitialized'; | 
|  | 24 |  |  |  |  | 38 |  | 
|  | 24 |  |  |  |  | 8176 |  | 
| 51 | 0 |  |  |  |  |  | foreach( @{ $s->{system}->{libs}->{lib} } ) | 
|  | 0 |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | { | 
| 53 | 0 |  |  |  |  |  | $_ =~ s/\@ServerRoot\@/$root/; | 
| 54 |  |  |  |  |  |  | }# end foreach() | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 0 |  |  |  |  |  | foreach( @{ $s->{system}->{settings}->{setting} } ) | 
|  | 0 |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | { | 
| 58 | 0 |  |  |  |  |  | $_->{value} =~ s/\@ServerRoot\@/$root/; | 
| 59 |  |  |  |  |  |  | }# end foreach() | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 0 |  |  |  |  |  | foreach my $key (qw/ application handler media_manager_upload www page_cache /) | 
| 62 |  |  |  |  |  |  | { | 
| 63 | 0 |  |  |  |  |  | $s->{web}->{"$key\_root"} =~ s/\@ServerRoot\@/$root/; | 
| 64 |  |  |  |  |  |  | }# end foreach() | 
| 65 |  |  |  |  |  |  | }# end init_server_root() | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | #============================================================================== | 
| 69 |  |  |  |  |  |  | sub load_class | 
| 70 |  |  |  |  |  |  | { | 
| 71 | 0 |  |  | 0 | 0 |  | my ($s, $class) = @_; | 
| 72 |  |  |  |  |  |  |  | 
| 73 | 0 |  |  |  |  |  | (my $file = "$class.pm") =~ s/::/\//g; | 
| 74 | 0 | 0 |  |  |  |  | eval { require $file unless $INC{$file}; 1 } | 
|  | 0 | 0 |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | or confess "Cannot load $class: $@"; | 
| 76 |  |  |  |  |  |  | }# end load_class() | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | sub DESTROY | 
| 80 |  |  |  |  |  |  | { | 
| 81 | 0 |  |  | 0 |  |  | my $s = shift; | 
| 82 | 0 |  |  |  |  |  | undef(%$s); | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | 1;# return true: | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =pod | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 NAME | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | Apache2::ASP::Config - Central configuration for Apache2::ASP | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | # Settings: | 
| 97 |  |  |  |  |  |  | $Config->system->settings->some_setting; | 
| 98 |  |  |  |  |  |  | $Config->system->settings->another_setting; | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | # Error-handling: | 
| 101 |  |  |  |  |  |  | $Config->errors->error_handler; | 
| 102 |  |  |  |  |  |  | $Config->errors->mail_errors_to; | 
| 103 |  |  |  |  |  |  | $Config->errors->mail_errors_from; | 
| 104 |  |  |  |  |  |  | $Config->errors->smtp_server; | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | # Web: | 
| 107 |  |  |  |  |  |  | $Config->web->application_name; | 
| 108 |  |  |  |  |  |  | $Config->web->application_root; | 
| 109 |  |  |  |  |  |  | $Config->web->www_root; | 
| 110 |  |  |  |  |  |  | $Config->web->handler_root; | 
| 111 |  |  |  |  |  |  | $Config->web->media_manager_upload_root; | 
| 112 |  |  |  |  |  |  | $Config->web->page_cache_root; | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | # Data Connections: | 
| 115 |  |  |  |  |  |  | foreach my $conn ( map { $Config->data_connections->$_ } qw/ session application main / ) | 
| 116 |  |  |  |  |  |  | { | 
| 117 |  |  |  |  |  |  | my $dbh = DBI->connect( | 
| 118 |  |  |  |  |  |  | $conn->dsn, | 
| 119 |  |  |  |  |  |  | $conn->username, | 
| 120 |  |  |  |  |  |  | $conn->password | 
| 121 |  |  |  |  |  |  | ); | 
| 122 |  |  |  |  |  |  | }# end foreach() | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 XML Config File | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | Apache2::ASP keeps all of its configuration inside of C | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | Here is an example: | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | @ServerRoot@/lib | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | DBI | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | myvar | 
| 151 |  |  |  |  |  |  | value | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | myvar2 | 
| 155 |  |  |  |  |  |  | value2 | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | mysetting | 
| 162 |  |  |  |  |  |  | value | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | mysetting2 | 
| 166 |  |  |  |  |  |  | value2 | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | My::ErrorHandler | 
| 173 |  |  |  |  |  |  | jdrago_999@yahoo.com | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | root@localhost | 
| 176 |  |  |  |  |  |  | localhost | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | DefaultApp | 
| 181 |  |  |  |  |  |  | @ServerRoot@ | 
| 182 |  |  |  |  |  |  | @ServerRoot@/handlers | 
| 183 |  |  |  |  |  |  | @ServerRoot@/MEDIA | 
| 184 |  |  |  |  |  |  | @ServerRoot@/htdocs | 
| 185 |  |  |  |  |  |  | @ServerRoot@/PAGE_CACHE | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  |  | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | Apache2::ASP::SessionStateManager::SQLite | 
| 204 |  |  |  |  |  |  | session-id | 
| 205 |  |  |  |  |  |  | DBI:SQLite:dbname=/tmp/apache2_asp_applications | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  | 30 | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  |  | 
| 211 |  |  |  |  |  |  | Apache2::ASP::ApplicationStateManager::SQLite | 
| 212 |  |  |  |  |  |  | DBI:SQLite:dbname=/tmp/apache2_asp_applications | 
| 213 |  |  |  |  |  |  |  | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | DBI:SQLite:dbname=/tmp/apache2_asp_applications | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  |  | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  |  | 
| 226 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 227 |  |  |  |  |  |  |  | 
| 228 |  |  |  |  |  |  | =head1 PUBLIC PROPERTIES | 
| 229 |  |  |  |  |  |  |  | 
| 230 |  |  |  |  |  |  | =head1 PUBLIC METHODS | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | =head1 BUGS | 
| 233 |  |  |  |  |  |  |  | 
| 234 |  |  |  |  |  |  | It's possible that some bugs have found their way into this release. | 
| 235 |  |  |  |  |  |  |  | 
| 236 |  |  |  |  |  |  | Use RT L to submit bug reports. | 
| 237 |  |  |  |  |  |  |  | 
| 238 |  |  |  |  |  |  | =head1 HOMEPAGE | 
| 239 |  |  |  |  |  |  |  | 
| 240 |  |  |  |  |  |  | Please visit the Apache2::ASP homepage at L to see examples | 
| 241 |  |  |  |  |  |  | of Apache2::ASP in action. | 
| 242 |  |  |  |  |  |  |  | 
| 243 |  |  |  |  |  |  | =head1 AUTHOR | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | John Drago | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 248 |  |  |  |  |  |  |  | 
| 249 |  |  |  |  |  |  | Copyright 2008 John Drago.  All rights reserved. | 
| 250 |  |  |  |  |  |  |  | 
| 251 |  |  |  |  |  |  | =head1 LICENSE | 
| 252 |  |  |  |  |  |  |  | 
| 253 |  |  |  |  |  |  | This software is Free software and is licensed under the same terms as perl itself. | 
| 254 |  |  |  |  |  |  |  | 
| 255 |  |  |  |  |  |  | =cut | 
| 256 |  |  |  |  |  |  |  |