ASP/HTTPHandler.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 81 CC 3 SCAR 11.2
CC
3
Cov
0%
init_asp_objects
6.0
modes
6.0
BEGIN
2.0
CRAP 3.1
1  
2 package Apache2::ASP::HTTPHandler;
3  
4 use strict;
5 use warnings 'all';
6 BEGIN {
7 use vars '@VARS';
8 our @VARS = qw(
9 $Request $Response
10 $Server $Application
11 $Session $Form
12 $Config $Stash
13 %modes
14 );
15 sub VARS { @VARS }
16 }
17 use vars __PACKAGE__->VARS;
18  
19  
20 #==============================================================================
21 sub new
22 {
23 my ($class) = shift;
24  
25 #warn "$class: new: " . caller;
26 return bless { @_ }, $class;
27 }# end new()
28  
29  
30 #==============================================================================
31 sub before_run { 1; }
32 sub after_run { }
33 sub run;
34  
35  
36 #==============================================================================
37 sub init_asp_objects
38 {
39 my ($s, $context) = @_;
40
41 no strict 'refs';
42 my $selfclass = ref($s) ? ref($s) : $s;
43
44 # Get each of this classes' superclasses, and theirs as well, recursively:
45 my %c = map { $_ => 1 } (
46 grep { $_->isa('Apache2::ASP::HTTPHandler') }
47 ( $selfclass, @{"$selfclass\::ISA"} )
48 );
49 map { $c{$_}++ } map {
50 @{"$_\::ISA"}
51 } keys(%c);
52 my @classes = keys(%c);
53
54 my (
55 $request, $response,
56 $server, $session,
57 $application, $config,
58 $form, $stash
59 ) = (
60 $context->request,
61 $context->response,
62 $context->server,
63 $context->session,
64 $context->application,
65 $context->config,
66 $context->request->Form,
67 $context->stash
68 );
69
70 foreach my $class ( @classes )
71 {
72 ${"$class\::Request"} = $request;
73 ${"$class\::Response"} = $response;
74 ${"$class\::Server"} = $server;
75 ${"$class\::Session"} = $session;
76 ${"$class\::Application"} = $application;
77 ${"$class\::Config"} = $config;
78 ${"$class\::Form"} = $form;
79 ${"$class\::Stash"} = $stash;
80 }# end foreach()
81  
82 1;
83 }# end init_asp_objects()
84
85
86 #==============================================================================
87 sub register_mode
88 {
89 my ($s, %info) = @_;
90
91 $modes{ $info{name} } = $info{handler};
92 }# end register_mode()
93  
94
95 #==============================================================================
96 sub modes
97 {
98 my $s = shift;
99 my $key = shift;
100
101 @_ ? $modes{$key} = shift : $modes{$key};
102 }# end modes()
103  
104 1;# return true:
105  
106 =pod
107  
108 =head1 NAME
109  
110 Apache2::ASP::HTTPHandler - base HTTP handler class
111  
112 =head1 SYNOPSIS
113  
114 Internal use only.
115  
116 =head1 DESCRIPTION
117  
118 All *Handlers (FormHandlers, ErrorHandlers, UploadHandlers, etc) are subclasses
119 of this class.
120  
121 HTTPHandler provides the mechanism for inheriting and initializing the ASP
122 objects ($Request, $Response, $Session, $Server, etc) in itself and all of its
123 subclasses, recursively.
124  
125 =head1 PUBLIC METHODS
126  
127 =head2 VARS
128  
129 This shoud be called by every *Handler and MediaManager subclass.
130  
131 Returns a list of strings like this:
132  
133 qw(
134 $Response $Application
135 $Request $Stash
136 $Config $Form
137 $Server $Session
138 );
139
140 =head1 BUGS
141
142 It's possible that some bugs have found their way into this release.
143
144 Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP> to submit bug reports.
145
146 =head1 HOMEPAGE
147
148 Please visit the Apache2::ASP homepage at L<http://www.devstack.com/> to see examples
149 of Apache2::ASP in action.
150
151 =head1 AUTHOR
152
153 John Drago L<mailto:jdrago_999@yahoo.com>
154
155 =head1 COPYRIGHT AND LICENSE
156
157 Copyright 2007 John Drago, All rights reserved.
158
159 This software is free software. It may be used and distributed under the
160 same terms as Perl itself.
161
162 =cut