[Catalyst-commits] r10303 - in trunk/Catalyst-Controller-WrapCGI: .
lib/Catalyst/Controller lib/CatalystX t t/lib/TestApp/Controller
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Tue May 26 22:46:25 GMT 2009
Author: caelum
Date: 2009-05-26 22:46:25 +0000 (Tue, 26 May 2009)
New Revision: 10303
Modified:
trunk/Catalyst-Controller-WrapCGI/Changes
trunk/Catalyst-Controller-WrapCGI/Makefile.PL
trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm
trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm
trunk/Catalyst-Controller-WrapCGI/lib/CatalystX/GlobalContext.pm
trunk/Catalyst-Controller-WrapCGI/t/lib/TestApp/Controller/Root.pm
trunk/Catalyst-Controller-WrapCGI/t/wrap-cgi.t
Log:
->req->remote_user support, new release
Modified: trunk/Catalyst-Controller-WrapCGI/Changes
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/Changes 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/Changes 2009-05-26 22:46:25 UTC (rev 10303)
@@ -1,5 +1,9 @@
Revision history for Catalyst-Controller-WrapCGI
+0.016 2009-05-26 22:35:09
+ - fallback to $c->req->remote_user for $ENV{REMOTE_USER}
+ - fix POD
+
0.0037 2009-05-06 20:07:00
- pass captures in SCRIPT_NAME (caelum)
Modified: trunk/Catalyst-Controller-WrapCGI/Makefile.PL
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/Makefile.PL 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/Makefile.PL 2009-05-26 22:46:25 UTC (rev 10303)
@@ -21,8 +21,7 @@
build_requires 'Test::More' => '0.86';
+auto_provides;
auto_install;
-
resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Controller-WrapCGI/';
-
WriteAll;
Modified: trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm 2009-05-26 22:46:25 UTC (rev 10303)
@@ -23,11 +23,11 @@
=head1 VERSION
-Version 0.015
+Version 0.016
=cut
-our $VERSION = '0.015';
+our $VERSION = '0.016';
=head1 SYNOPSIS
@@ -154,7 +154,7 @@
=head2 cgi_action
-C<<$self->cgi_action($cgi)>>
+C<< $self->cgi_action($cgi) >>
Takes a path to a CGI from C<root/cgi-bin> such as C<foo/bar.cgi> and returns
the action name it is registered as. See L</DESCRIPTION> for a discussion on how
@@ -182,7 +182,7 @@
=head2 cgi_path
-C<<$self->cgi_path($cgi)>>
+C<< $self->cgi_path($cgi) >>
Takes a path to a CGI from C<root/cgi-bin> such as C<foo/bar.cgi> and returns
the public path it should be registered under.
@@ -202,7 +202,7 @@
=head2 is_perl_cgi
-C<<$self->is_perl_cgi($path)>>
+C<< $self->is_perl_cgi($path) >>
Tries to figure out whether the CGI is Perl or not.
@@ -230,7 +230,7 @@
=head2 wrap_perl_cgi
-C<<$self->wrap_perl_cgi($path, $action_name)>>
+C<< $self->wrap_perl_cgi($path, $action_name) >>
Takes the path to a Perl CGI and returns a coderef suitable for passing to
cgi_to_response (from L<Catalyst::Controller::WrapCGI>.)
@@ -294,7 +294,7 @@
=head2 wrap_nonperl_cgi
-C<<$self->wrap_nonperl_cgi($path, $action_name)>>
+C<< $self->wrap_nonperl_cgi($path, $action_name) >>
Takes the path to a non-Perl CGI and returns a coderef for executing it.
Modified: trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm 2009-05-26 22:46:25 UTC (rev 10303)
@@ -20,11 +20,11 @@
=head1 VERSION
-Version 0.0037
+Version 0.016
=cut
-our $VERSION = '0.0037';
+our $VERSION = '0.016';
=head1 SYNOPSIS
@@ -66,6 +66,9 @@
If you just want to run CGIs from files, see L<Catalyst::Controller::CGIBin>.
+C<REMOTE_USER> will be set to C<< $c->user->obj->$username_field >> if
+available, or to C<< $c->req->remote_user >> otherwise.
+
=head1 CONFIGURATION
=head2 pass_env
@@ -104,7 +107,7 @@
=head2 cgi_to_response
-C<<$self->cgi_to_response($c, $coderef)>>
+C<< $self->cgi_to_response($c, $coderef) >>
Does the magic of running $coderef in a CGI environment, and populating the
appropriate parts of your Catalyst context with the results.
@@ -134,16 +137,17 @@
=head2 wrap_cgi
-C<<$self->wrap_cgi($c, $coderef)>>
+C<< $self->wrap_cgi($c, $coderef) >>
Runs $coderef in a CGI environment using L<HTTP::Request::AsCGI>, returns an
L<HTTP::Response>.
-The CGI environment is set up based on $c.
+The CGI environment is set up based on C<$c>.
The environment variables to pass on are taken from the configuration for your
Controller, see L</SYNOPSIS> for an example. If you don't supply a list of
-environment variables to pass, the whole of %ENV is used.
+environment variables to pass, the whole of %ENV is used (with exceptions listed
+in L</FILTERED ENVIRONMENT>.
Used by L</cgi_to_response>, which is probably what you want to use as well.
@@ -203,6 +207,8 @@
? eval { $c->user->obj->$username_field }
: '');
+ $username ||= $c->req->remote_user if $c->req->can('remote_user');
+
my $path_info = '/'.join '/' => map {
utf8::is_utf8($_) ? uri_escape_utf8($_) : uri_escape($_)
} @{ $c->req->args };
Modified: trunk/Catalyst-Controller-WrapCGI/lib/CatalystX/GlobalContext.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/lib/CatalystX/GlobalContext.pm 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/lib/CatalystX/GlobalContext.pm 2009-05-26 22:46:25 UTC (rev 10303)
@@ -15,11 +15,11 @@
=head1 VERSION
-Version 0.01
+Version 0.016
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.016';
=head1 SYNOPSIS
Modified: trunk/Catalyst-Controller-WrapCGI/t/lib/TestApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/lib/TestApp/Controller/Root.pm 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/t/lib/TestApp/Controller/Root.pm 2009-05-26 22:46:25 UTC (rev 10303)
@@ -57,4 +57,14 @@
});
}
+sub test_remote_user : Path('/cgi-bin/test_remote_user.cgi') Args(0) {
+ my ($self, $c) = @_;
+
+ $self->cgi_to_response($c, sub {
+ my $cgi = CGI->new;
+ print $cgi->header;
+ print $ENV{REMOTE_USER}
+ });
+}
+
1;
Modified: trunk/Catalyst-Controller-WrapCGI/t/wrap-cgi.t
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/wrap-cgi.t 2009-05-26 22:34:21 UTC (rev 10302)
+++ trunk/Catalyst-Controller-WrapCGI/t/wrap-cgi.t 2009-05-26 22:46:25 UTC (rev 10303)
@@ -6,7 +6,7 @@
use FindBin '$Bin';
use lib "$Bin/lib";
-use Test::More tests => 6;
+use Test::More tests => 7;
use Catalyst::Test 'TestApp';
use HTTP::Request::Common;
@@ -52,3 +52,7 @@
$response = request '/cgi-bin/mtfnpy/test_scriptname.cgi/foo/bar';
is($response->content, '/cgi-bin/mtfnpy/test_scriptname.cgi',
'SCRIPT_NAME is correct');
+
+$ENV{REMOTE_USER} = 'TEST_USER';
+$response = request '/cgi-bin/test_remote_user.cgi';
+is($response->content, 'TEST_USER', 'REMOTE_USER was passed');
More information about the Catalyst-commits
mailing list