Skip to content

Commit

Permalink
Fix a number of issues that arise when mod_perl is not installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
martink committed Jul 13, 2012
1 parent b1bb15e commit 544a62d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
5 changes: 4 additions & 1 deletion etc/dev.localhost.localdomain.psgi
@@ -1,5 +1,8 @@
use Plack::Builder;
use lib '/data/WebGUI/lib';

my $webgui_lib = '/data/WebGUI/lib';
use lib $webgui_lib, $webgui_lib.'/plebgui_mock';

use WebGUI;
WebGUI->init( root => '/data/WebGUI', config => 'dev.localhost.localdomain.conf' );

Expand Down
19 changes: 11 additions & 8 deletions lib/WebGUI.pm
@@ -1,10 +1,8 @@
package WebGUI;


our $VERSION = '7.10.24';
our $STATUS = 'stable';


=head1 LEGAL
-------------------------------------------------------------------
Expand All @@ -20,13 +18,18 @@ our $STATUS = 'stable';
=cut

use strict;
use Apache2::Access ();
use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED SERVER_ERROR);
use Apache2::Request;
use Apache2::RequestIO;
use Apache2::RequestUtil ();
use Apache2::ServerUtil ();
use APR::Request::Apache2;

# Eval loading the mod_perl modules as they might not be installed when running under plack.
eval q{
require Apache2::Access ();
require Apache2::Request;
require Apache2::RequestIO;
require Apache2::RequestUtil ();
require Apache2::ServerUtil ();
require APR::Request::Apache2;
};

use MIME::Base64 ();
use Scalar::Util qw/blessed/;
use WebGUI::Config;
Expand Down
15 changes: 9 additions & 6 deletions lib/WebGUI/URL/Content.pm
Expand Up @@ -43,7 +43,7 @@ These subroutines are available from this package:

#-------------------------------------------------------------------

=head2 handler ( request, server, config )
=head2 handler ( request, server, config )
The Apache request handler for this package.
Expand All @@ -64,9 +64,12 @@ to the user, instead of displaying the Page Not Found page.
sub handler {
my ($request, $server, $config) = @_;
$request->push_handlers(PerlResponseHandler => sub {

my $request = shift;
$request = Apache2::Request->new($request);

if (! $request->isa('WebGUI::Session::Plack') ){
require Apache2::Request;
$request = Apache2::Request->new($request);
}

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

Expand All @@ -84,9 +87,9 @@ sub handler {
WebGUI::authen($request, split(":", MIME::Base64::decode_base64($auth), 2), $session);
}
else { # realm oriented
$request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $session)});
}
}
$request->push_handlers(PerlAuthenHandler => sub { return WebGUI::authen($request, undef, undef, $session)});
}
}

WebGUI::Asset::Template->processVariableHeaders($session);
foreach my $handler (@{$config->get("contentHandlers")}) {
Expand Down
9 changes: 9 additions & 0 deletions lib/plebgui_mock/APR/Date.pm
@@ -0,0 +1,9 @@
package APR::Date;

use DateTime::Format::HTTP;

sub parse_http {
return DateTime::Format::HTTP->parse_datetime( shift )->epoch;
}

1;
9 changes: 9 additions & 0 deletions lib/plebgui_mock/Apache2/Const.pm
@@ -0,0 +1,9 @@
package Apache2::Const;

sub OK { 1 }
sub DECLINED {1}
sub HTTP_UNAUTHORIZED {1}
sub SERVER_ERROR {1}


1;

0 comments on commit 544a62d

Please sign in to comment.