Parent Directory
|
Revision Log
moved PG modules and macro files from webwork-modperl to pg -sam
1 ################################################################################ 2 # WeBWorK mod_perl (c) 2000-2002 WeBWorK Project 3 # $Id$ 4 ################################################################################ 5 6 package Apache::WeBWorK; 7 8 =head1 NAME 9 10 Apache::WeBWorK - mod_perl handler for WeBWorK. 11 12 =head1 CONFIGURATION 13 14 This module should be installed as a Handler for the location selected for 15 WeBWorK on your webserver. Here is an example of a stanza that can be added to 16 your httpd.conf file to achieve this: 17 18 <IfModule mod_perl.c> 19 PerlFreshRestart On 20 <Location /webwork2> 21 SetHandler perl-script 22 PerlHandler Apache::WeBWorK 23 PerlSetVar webwork_root /path/to/webwork-modperl 24 <Perl> 25 use lib '/path/to/webwork-modperl/lib'; 26 use lib '/path/to/pg/lib'; 27 </Perl> 28 </Location> 29 </IfModule> 30 31 =cut 32 33 use strict; 34 use warnings; 35 use WeBWorK; # leave compile-time errors alone. 36 37 sub handler($) { 38 my ($r) = @_; 39 my $result = eval { 40 WeBWorK::dispatch($r) 41 }; 42 if ($@) { 43 my $message = message($r, $@); 44 unless ($r->bytes_sent) { 45 $message = "<html><body>$message</body></html>"; 46 $r->content_type("text/html"); 47 $r->send_http_header; 48 } 49 $r->print($message); 50 die $@; 51 } 52 return $result; 53 } 54 55 sub message($$) { 56 my ($r, $exception) = @_; 57 58 my $admin = ($ENV{SERVER_ADMIN} 59 ? "(<a href=\"mailto:$ENV{SERVER_ADMIN}\">$ENV{SERVER_ADMIN}</a>)" 60 : ""); 61 # Error context doesn't work yet -- calling longmess() from here is stupid 62 #my $context = Carp::longmess(); 63 my $method = $r->method; 64 my $uri = $r->uri; 65 my $headers = do { 66 my %headers = $r->headers_in; 67 join("", map { "<tr><td>$_</td><td>$headers{$_}</td></tr>" } keys %headers); 68 }; 69 70 return <<EOF; 71 <div align="left"> 72 <h1>Software Error</h1> 73 <p>An error has occured while trying to process you request. For help, please send mail to this site's webmaster $admin giving the following information about the error and the date and time that the error occured.</p> 74 <h2>Error message</h2> 75 <pre>$exception</pre> 76 <h2>Request information</h2> 77 <dl> 78 <dt>Method</dt> 79 <dd>$method</dd> 80 <dt>URI</dt> 81 <dd>$uri</dd> 82 </dl> 83 <h2>Headers received</h2> 84 <table>$headers</table> 85 </div> 86 EOF 87 # <h2>Error context</h2> 88 # <blockquote> 89 # <pre>$context</pre> 90 # </blockquote> 91 } 92 93 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |