| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork2/lib/WeBWorK/Request.pm,v 1.3 2005/11/07 21:18:13 sh002i Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK/Request.pm,v 1.4 2006/01/25 23:13:51 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 13 | # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the |
13 | # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the |
| 14 | # Artistic License for more details. |
14 | # Artistic License for more details. |
| 15 | ################################################################################ |
15 | ################################################################################ |
| 16 | |
16 | |
| 17 | package WeBWorK::Request; |
17 | package WeBWorK::Request; |
| 18 | use base qw(Apache::Request); |
|
|
| 19 | |
18 | |
| 20 | =head1 NAME |
19 | =head1 NAME |
| 21 | |
20 | |
| 22 | WeBWorK::Request - a request to the WeBWorK system, a subclass of |
21 | WeBWorK::Request - a request to the WeBWorK system, a subclass of |
| 23 | Apache::Request with additional WeBWorK-specific fields. |
22 | Apache::Request with additional WeBWorK-specific fields. |
| 24 | |
23 | |
| 25 | =cut |
24 | =cut |
| 26 | |
25 | |
| 27 | use strict; |
26 | use strict; |
| 28 | use warnings; |
27 | use warnings; |
|
|
28 | |
|
|
29 | use mod_perl; |
|
|
30 | use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 ); |
|
|
31 | |
|
|
32 | # This class inherits from Apache::Request under mod_perl and Apache2::Request under mod_perl2 |
|
|
33 | BEGIN { |
|
|
34 | if (MP2) { |
|
|
35 | require Apache2::Request; |
|
|
36 | Apache2::Request->import; |
|
|
37 | push @WeBWorK::Request::ISA, "Apache2::Request"; |
|
|
38 | } else { |
|
|
39 | require Apache::Request; |
|
|
40 | Apache::Request->import; |
|
|
41 | push @WeBWorK::Request::ISA, "Apache::Request"; |
|
|
42 | } |
|
|
43 | } |
| 29 | |
44 | |
| 30 | =head1 CONSTRUCTOR |
45 | =head1 CONSTRUCTOR |
| 31 | |
46 | |
| 32 | =over |
47 | =over |
| 33 | |
48 | |
| … | |
… | |
| 49 | =cut |
64 | =cut |
| 50 | |
65 | |
| 51 | sub new { |
66 | sub new { |
| 52 | my ($invocant, @args) = @_; |
67 | my ($invocant, @args) = @_; |
| 53 | my $class = ref $invocant || $invocant; |
68 | my $class = ref $invocant || $invocant; |
|
|
69 | # construct the appropriate superclass instance depending on mod_perl version |
|
|
70 | my $apreq_class = MP2 ? "Apache2::Request" : "Apache::Request"; |
| 54 | return bless { r => Apache::Request->new(@args) }, $class; |
71 | return bless { r => $apreq_class->new(@args) }, $class; |
| 55 | } |
72 | } |
| 56 | |
73 | |
| 57 | =back |
74 | =back |
| 58 | |
75 | |
| 59 | =cut |
76 | =cut |