Skip to content

Commit 544a62d

Browse files
committedJul 13, 2012
Fix a number of issues that arise when mod_perl is not installed.
1 parent b1bb15e commit 544a62d

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed
 

‎etc/dev.localhost.localdomain.psgi

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use Plack::Builder;
2-
use lib '/data/WebGUI/lib';
2+
3+
my $webgui_lib = '/data/WebGUI/lib';
4+
use lib $webgui_lib, $webgui_lib.'/plebgui_mock';
5+
36
use WebGUI;
47
WebGUI->init( root => '/data/WebGUI', config => 'dev.localhost.localdomain.conf' );
58

‎lib/WebGUI.pm

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package WebGUI;
22

3-
43
our $VERSION = '7.10.24';
54
our $STATUS = 'stable';
65

7-
86
=head1 LEGAL
97
108
-------------------------------------------------------------------
@@ -20,13 +18,18 @@ our $STATUS = 'stable';
2018
=cut
2119

2220
use strict;
23-
use Apache2::Access ();
2421
use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED SERVER_ERROR);
25-
use Apache2::Request;
26-
use Apache2::RequestIO;
27-
use Apache2::RequestUtil ();
28-
use Apache2::ServerUtil ();
29-
use APR::Request::Apache2;
22+
23+
# Eval loading the mod_perl modules as they might not be installed when running under plack.
24+
eval q{
25+
require Apache2::Access ();
26+
require Apache2::Request;
27+
require Apache2::RequestIO;
28+
require Apache2::RequestUtil ();
29+
require Apache2::ServerUtil ();
30+
require APR::Request::Apache2;
31+
};
32+
3033
use MIME::Base64 ();
3134
use Scalar::Util qw/blessed/;
3235
use WebGUI::Config;

‎lib/WebGUI/URL/Content.pm

+9-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ These subroutines are available from this package:
4343

4444
#-------------------------------------------------------------------
4545

46-
=head2 handler ( request, server, config )
46+
=head2 handler ( request, server, config )
4747
4848
The Apache request handler for this package.
4949
@@ -64,9 +64,12 @@ to the user, instead of displaying the Page Not Found page.
6464
sub handler {
6565
my ($request, $server, $config) = @_;
6666
$request->push_handlers(PerlResponseHandler => sub {
67-
6867
my $request = shift;
69-
$request = Apache2::Request->new($request);
68+
69+
if (! $request->isa('WebGUI::Session::Plack') ){
70+
require Apache2::Request;
71+
$request = Apache2::Request->new($request);
72+
}
7073

7174
my $session = $request->pnotes('wgSession');
7275

@@ -84,9 +87,9 @@ sub handler {
8487
WebGUI::authen($request, split(":", MIME::Base64::decode_base64($auth), 2), $session);
8588
}
8689
else { # realm oriented
87-
$request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $session)});
88-
}
89-
}
90+
$request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $session)});
91+
}
92+
}
9093

9194
WebGUI::Asset::Template->processVariableHeaders($session);
9295
foreach my $handler (@{$config->get("contentHandlers")}) {

‎lib/plebgui_mock/APR/Date.pm

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package APR::Date;
2+
3+
use DateTime::Format::HTTP;
4+
5+
sub parse_http {
6+
return DateTime::Format::HTTP->parse_datetime( shift )->epoch;
7+
}
8+
9+
1;

‎lib/plebgui_mock/Apache2/Const.pm

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package Apache2::Const;
2+
3+
sub OK { 1 }
4+
sub DECLINED {1}
5+
sub HTTP_UNAUTHORIZED {1}
6+
sub SERVER_ERROR {1}
7+
8+
9+
1;

0 commit comments

Comments
 (0)
Please sign in to comment.