[system] / branches / rel-2-4-patches / webwork2 / lib / WeBWorK / Request.pm Repository:
ViewVC logotype

Annotation of /branches/rel-2-4-patches/webwork2/lib/WeBWorK/Request.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4192 - (view) (download) (as text)
Original Path: trunk/webwork2/lib/WeBWorK/Request.pm

1 : sh002i 1842 ################################################################################
2 :     # WeBWorK Online Homework Delivery System
3 : sh002i 3973 # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/
4 : sh002i 4192 # $CVSHeader: webwork2/lib/WeBWorK/Request.pm,v 1.4 2006/01/25 23:13:51 sh002i Exp $
5 : sh002i 1842 #
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
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.
10 :     #
11 :     # This program is distributed in the hope that it will be useful, but WITHOUT
12 :     # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 :     # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the
14 :     # Artistic License for more details.
15 :     ################################################################################
16 :    
17 :     package WeBWorK::Request;
18 :    
19 :     =head1 NAME
20 :    
21 :     WeBWorK::Request - a request to the WeBWorK system, a subclass of
22 :     Apache::Request with additional WeBWorK-specific fields.
23 :    
24 :     =cut
25 :    
26 :     use strict;
27 :     use warnings;
28 :    
29 : sh002i 4192 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 :     }
44 :    
45 : sh002i 1842 =head1 CONSTRUCTOR
46 :    
47 :     =over
48 :    
49 :     =item new(@args)
50 :    
51 :     Creates an new WeBWorK::Request. All arguments are passed to Apache::Request's
52 :     constructor. You must specify at least an Apache request_rec object.
53 :    
54 :     =for comment
55 :    
56 :     From: http://search.cpan.org/~joesuf/libapreq-1.3/Request/Request.pm#SUBCLASSING_Apache::Request
57 :    
58 :     If the instances of your subclass are hash references then you can actually
59 :     inherit from Apache::Request as long as the Apache::Request object is stored in
60 :     an attribute called "r" or "_r". (The Apache::Request class effectively does the
61 :     delegation for you automagically, as long as it knows where to find the
62 :     Apache::Request object to delegate to.)
63 :    
64 :     =cut
65 :    
66 :     sub new {
67 :     my ($invocant, @args) = @_;
68 :     my $class = ref $invocant || $invocant;
69 : sh002i 4192 # construct the appropriate superclass instance depending on mod_perl version
70 :     my $apreq_class = MP2 ? "Apache2::Request" : "Apache::Request";
71 :     return bless { r => $apreq_class->new(@args) }, $class;
72 : sh002i 1842 }
73 :    
74 : sh002i 2955 =back
75 :    
76 :     =cut
77 :    
78 : sh002i 1842 =head1 METHODS
79 :    
80 :     =over
81 :    
82 :     =item ce([$new])
83 :    
84 :     Return the course environment (WeBWorK::CourseEnvironment) associated with this
85 :     request. If $new is specified, set the course environment to $new before
86 :     returning the value.
87 :    
88 :     =cut
89 :    
90 :     sub ce {
91 :     my $self = shift;
92 :     $self->{ce} = shift if @_;
93 :     return $self->{ce};
94 :     }
95 :    
96 :     =item db([$new])
97 :    
98 :     Return the database (WeBWorK::DB) associated with this request. If $new is
99 :     specified, set the database to $new before returning the value.
100 :    
101 :     =cut
102 :    
103 :     sub db {
104 :     my $self = shift;
105 :     $self->{db} = shift if @_;
106 :     return $self->{db};
107 :     }
108 :    
109 : sh002i 3742 =item authen([$new])
110 :    
111 :     Return the authenticator (WeBWorK::Authen) associated with this request. If $new
112 :     is specified, set the authenticator to $new before returning the value.
113 :    
114 :     =cut
115 :    
116 :     sub authen {
117 :     my $self = shift;
118 :     $self->{authen} = shift if @_;
119 :     return $self->{authen};
120 :     }
121 :    
122 : sh002i 1842 =item authz([$new])
123 :    
124 :     Return the authorizer (WeBWorK::Authz) associated with this request. If $new is
125 :     specified, set the authorizer to $new before returning the value.
126 :    
127 :     =cut
128 :    
129 :     sub authz {
130 :     my $self = shift;
131 :     $self->{authz} = shift if @_;
132 :     return $self->{authz};
133 :     }
134 :    
135 :     =item urlpath([$new])
136 :    
137 :     Return the URL path (WeBWorK::URLPath) associated with this request. If $new is
138 :     specified, set the URL path to $new before returning the value.
139 :    
140 :     =cut
141 :    
142 :     sub urlpath {
143 :     my $self = shift;
144 :     $self->{urlpath} = shift if @_;
145 :     return $self->{urlpath};
146 :     }
147 :    
148 :     =back
149 :    
150 :     =cut
151 :    
152 :     1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9