| 1 | |||
| 2 | package Apache2::ASP::ConfigNode::Web; | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use warnings 'all'; | ||
| 6 | use base 'Apache2::ASP::ConfigNode'; | ||
| 7 | |||
| 8 | |||
| 9 | #============================================================================== | ||
| 10 | sub new | ||
| 11 | { | ||
| 12 | my $class = shift; | ||
| 13 | |||
| 14 | my $s = $class->SUPER::new( @_ ); | ||
| 15 | $s->{handler_resolver} ||= 'Apache2::ASP::HTTPContext::HandlerResolver'; | ||
| 16 | $s->{handler_runner} ||= 'Apache2::ASP::HTTPContext::HandlerRunner'; | ||
| 17 | $s->{filter_resolver} ||= 'Apache2::ASP::HTTPContext::FilterResolver'; | ||
| 18 | |||
| 19 | map { | ||
| 20 | $_->{uri_match} = undef unless defined($_->{uri_match}); | ||
| 21 | $_->{uri_equals} = undef unless defined($_->{uri_equals}); | ||
| 22 | $_ = $class->SUPER::new( $_ ); | ||
| 23 | } $s->request_filters; | ||
| 24 | map { | ||
| 25 | $_->{uri_match} = undef unless defined($_->{uri_match}); | ||
| 26 | $_->{uri_equals} = undef unless defined($_->{uri_equals}); | ||
| 27 | $_->{disable_session} ||= 0; | ||
| 28 | $_->{disable_application} ||= 0; | ||
| 29 | $_ = $class->SUPER::new( $_ ); | ||
| 30 | } $s->disable_persistence; | ||
| 31 | return $s; | ||
| 32 | }# end new() | ||
| 33 | |||
| 34 | |||
| 35 | #============================================================================== | ||
| 36 | sub request_filters | ||
| 37 | { | ||
| 38 | my $s = shift; | ||
| 39 | |||
| 40 | @{ $s->{request_filters}->{filter} }; | ||
| 41 | }# end request_filters() | ||
| 42 | |||
| 43 | |||
| 44 | #============================================================================== | ||
| 45 | sub disable_persistence | ||
| 46 | { | ||
| 47 | my $s = shift; | ||
| 48 | |||
| 49 | @{ $s->{disable_persistence}->{location} }; | ||
| 50 | }# end disable_persistence() | ||
| 51 | |||
| 52 | 1;# return true: | ||
| 53 | |||
| 54 | =pod | ||
| 55 | |||
| 56 | =head1 NAME | ||
| 57 | |||
| 58 | Apache2::ASP::ConfigNode::Web - The $Config->web object. | ||
| 59 | |||
| 60 | =head1 SYNOPSIS | ||
| 61 | |||
| 62 | Given the following configuration... | ||
| 63 | |||
| 64 | <?xml version="1.0"?> | ||
| 65 | <config> | ||
| 66 | ... | ||
| 67 | <web> | ||
| 68 | <application_name>MyApp</application_name> | ||
| 69 | <application_root>@ServerRoot@</application_root> | ||
| 70 | <handler_root>@ServerRoot@/handlers</handler_root> | ||
| 71 | <media_manager_upload_root>@ServerRoot@/MEDIA</media_manager_upload_root> | ||
| 72 | <www_root>@ServerRoot@/htdocs</www_root> | ||
| 73 | <page_cache_root>/tmp/PAGE_CACHE</page_cache_root> | ||
| 74 | <request_filters> | ||
| 75 | <filter> | ||
| 76 | <uri_match>/members/.*</uri_match> | ||
| 77 | <class>My::MemberFilter</class> | ||
| 78 | </filter> | ||
| 79 | <filter> | ||
| 80 | <uri_match>/checkout/.*</uri_match> | ||
| 81 | <class>My::HasOrderFilter</class> | ||
| 82 | </filter> | ||
| 83 | </request_filters> | ||
| 84 | </web> | ||
| 85 | ... | ||
| 86 | </config> | ||
| 87 | |||
| 88 | You would access it like this: | ||
| 89 | |||
| 90 | $Config->web->application_name; # 'MyApp' | ||
| 91 | $Config->web->application_root; # '/usr/local/projects/mysite.com' | ||
| 92 | $Config->web->handler_root; # '/usr/local/projects/mysite.com/handlers' | ||
| 93 | $Config->web->media_manager_upload_root; # '/usr/local/projects/mysite.com/MEDIA' | ||
| 94 | $Config->web->www_root; # '/usr/local/projects/mysite.com/htdocs' | ||
| 95 | $Config->web->page_cache_root; # '/tmp/PAGE_CACHE' | ||
| 96 | |||
| 97 | You will never need to do this: | ||
| 98 | foreach my $filter ( $Config->web->request_filters ) | ||
| 99 | { | ||
| 100 | my $regexp = $filter->uri_match; | ||
| 101 | my $class = $filter->class; | ||
| 102 | }# end foreach() | ||
| 103 | |||
| 104 | =head1 DESCRIPTION | ||
| 105 | |||
| 106 | Apache2::ASP::ConfigNode::Web provides access to the C<web> portion of the configuration. | ||
| 107 | |||
| 108 | =head1 PUBLIC PROPERTIES | ||
| 109 | |||
| 110 | =head2 application_name | ||
| 111 | |||
| 112 | Returns the name of the application. | ||
| 113 | |||
| 114 | =head2 application_root | ||
| 115 | |||
| 116 | Returns the absolute path to the root of the application, i.e. C</usr/local/projects/mysite.com> | ||
| 117 | |||
| 118 | =head2 handler_root | ||
| 119 | |||
| 120 | Returns the absolute path to where the 'handlers' are installed, i.e. C</usr/local/projects/mysite.com/handlers> | ||
| 121 | |||
| 122 | =head2 media_manager_upload_root | ||
| 123 | |||
| 124 | Returns the absolute path to where uploaded files will be stored, i.e. C</usr/local/projects/mysite.com/MEDIA> | ||
| 125 | |||
| 126 | =head2 www_root | ||
| 127 | |||
| 128 | Returns the absolute path to where the normal website files (ASP, images, css, javascripts, etc) are located, | ||
| 129 | i.e. C</usr/local/projects/mysite.com/htdocs> | ||
| 130 | |||
| 131 | =head2 page_cache_root | ||
| 132 | |||
| 133 | Returns the absolute path to where 'compiled' ASP scripts are stored, i.e. C</tmp/PAGE_CACHE> | ||
| 134 | |||
| 135 | Since the 'compiled' ASP scripts are overwritten whenever the source ASP script has been changed on disk, | ||
| 136 | the webserver process must have read/write access to this location. | ||
| 137 | |||
| 138 | It is recommended that a temporary path is used - '/tmp' on most Linux distributions. | ||
| 139 | |||
| 140 | =head2 request_filters | ||
| 141 | |||
| 142 | Returns a list of ConfigNodes that represent individual C<filter> elements in the configuration. | ||
| 143 | |||
| 144 | =head1 SEE ALSO | ||
| 145 | |||
| 146 | L<Apache2::ASP::RequestFilter> | ||
| 147 | |||
| 148 | =head1 BUGS | ||
| 149 | |||
| 150 | It's possible that some bugs have found their way into this release. | ||
| 151 | |||
| 152 | Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP> to submit bug reports. | ||
| 153 | |||
| 154 | =head1 HOMEPAGE | ||
| 155 | |||
| 156 | Please visit the Apache2::ASP homepage at L<http://www.devstack.com/> to see examples | ||
| 157 | of Apache2::ASP in action. | ||
| 158 | |||
| 159 | =head1 AUTHOR | ||
| 160 | |||
| 161 | John Drago <jdrago_999@yahoo.com> | ||
| 162 | |||
| 163 | =head1 COPYRIGHT AND LICENSE | ||
| 164 | |||
| 165 | Copyright 2007 John Drago, All rights reserved. | ||
| 166 | |||
| 167 | This software is free software. It may be used and distributed under the | ||
| 168 | same terms as Perl itself. | ||
| 169 | |||
| 170 | =cut | ||
| 171 |