[Catalyst-commits] r9863 - in trunk/Catalyst-Controller-WrapCGI: . lib/Catalyst/Controller t t/lib t/lib/TestCGIBin/Controller t/lib/TestCGIBinRoot t/lib/TestCGIBinRoot/Controller t/lib/TestCGIBinRoot/root t/lib/TestCGIBinRoot/root/cgi-bin t/lib/TestCGIBinRoot/root/cgi-bin/path

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sun Apr 26 20:56:27 GMT 2009


Author: caelum
Date: 2009-04-26 21:56:27 +0100 (Sun, 26 Apr 2009)
New Revision: 9863

Added:
   trunk/Catalyst-Controller-WrapCGI/t/cgibin_root.t
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot.pm
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/Controller/
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/Controller/CGIHandler.pm
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/path/
   trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/path/test.pl
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/t/lib/TestCGIBin/Controller/CGIHandler.pm
Log:
C::C::CGIBin - new release

Modified: trunk/Catalyst-Controller-WrapCGI/Changes
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/Changes	2009-04-26 19:52:52 UTC (rev 9862)
+++ trunk/Catalyst-Controller-WrapCGI/Changes	2009-04-26 20:56:27 UTC (rev 9863)
@@ -1,33 +1,34 @@
 Revision history for Catalyst-Controller-WrapCGI
 
-0.001  2008-06-28 15:28:46
-    First complete dist.
+0.0029  2009-04-26 20:54:28
+    - Allow more control over public paths to CGIBin actions. (confound)
+    - Override exit() in CGIBin-wrapped Perl cgis to avoid terminating the
+      Catalyst process. (confound)
+    - Set (temporarily) $0 to the filename of the Perl cgi being executed.
+      (confound)
+    - cgi_root_path accessor, convert to Moose (caelum)
+    - slight rewrite of docs and a test for __DATA__ (caelum)
 
-0.002  2008-07-02 23:02:20
-    First release.
+0.0028  2009-04-24 04:40:39
+    - Add support for __DATA__ sections in cgis for C::CGIBin (caelum)
 
-0.0022  2008-07-04 02:52:52
-    Fixed test shell script portability and missing dep on Class::C3
+0.0027  2009-04-03 14:55:34
+    - Add 'kill_env' and default to killing 'MOD_PERL' from environment.
+    (confound)
 
-0.0024  2008-11-19 16:00:54
-    Fixed for Catalyst 5.8
+0.0026  2009-02-02
+    - Stop storing generated files in SVN and add svn:ignore.
+    - Remove taint from tests as this breaks in a local::lib environment
+      as PERL5LIB is stripped.
 
 0.0025  2009-01-09 14:59:20
-    Tell Static::Simple to ignore root/cgi-bin for C::C::CGIBin
+    - Tell Static::Simple to ignore root/cgi-bin for C::C::CGIBin (caelum)
 
-0.0026  2009-02-02
-    Stop storing generated files in SVN and add svn:ignore.
-    Remove taint from tests as this breaks in a local::lib environment
-    as PERL5LIB is stripped.
+0.0024  2008-11-19 16:00:54
+    - Fixed for Catalyst 5.8 (caelum)
 
-0.0027  2009-04-03 14:55:34
-    Add 'kill_env' and default to killing 'MOD_PERL' from environment.
+0.002  2008-07-02 23:02:20
+    - First release.
 
-0.0028  2009-04-24 04:40:39
-    Add support for __DATA__ sections in cgis for C::CGIBin
-
-0.0029
-    Allow more control over public paths to CGIBin actions.
-    Override exit() in CGIBin-wrapped Perl cgis to avoid terminating the
-    Catalyst process.
-    Set (temporarily) $0 to the filename of the Perl cgi being executed.
+0.001  2008-06-28 15:28:46
+    - First complete dist.

Modified: trunk/Catalyst-Controller-WrapCGI/Makefile.PL
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/Makefile.PL	2009-04-26 19:52:52 UTC (rev 9862)
+++ trunk/Catalyst-Controller-WrapCGI/Makefile.PL	2009-04-26 20:56:27 UTC (rev 9863)
@@ -15,7 +15,7 @@
 requires 'File::Slurp';
 requires 'namespace::clean';
 
-requires 'MRO::Compat';
+requires 'Moose';
 
 if($] < 5.009_005) {
     requires 'Class::C3::XS' => '0.08';

Modified: trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm	2009-04-26 19:52:52 UTC (rev 9862)
+++ trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/CGIBin.pm	2009-04-26 20:56:27 UTC (rev 9863)
@@ -1,10 +1,10 @@
 package Catalyst::Controller::CGIBin;
 
-use strict;
-use warnings;
+use Moose;
+use mro 'c3';
 
-use MRO::Compat;
-use mro 'c3';
+extends 'Catalyst::Controller::WrapCGI';
+
 use File::Slurp 'slurp';
 use File::Find::Rule ();
 use Catalyst::Exception ();
@@ -16,8 +16,6 @@
 use Carp;
 use namespace::clean -except => 'meta';
 
-use parent 'Catalyst::Controller::WrapCGI';
-
 =head1 NAME
 
 Catalyst::Controller::CGIBin - Serve CGIs from root/cgi-bin
@@ -39,7 +37,7 @@
     use parent qw/Catalyst::Controller::CGIBin/;
 
     # example of a forward to /cgi-bin/hlagh/mtfnpy.cgi
-    sub dongs : Local Args(0) {
+    sub serve_cgi : Local Args(0) {
         my ($self, $c) = @_;
         $c->forward($self->cgi_action('hlagh/mtfnpy.cgi'));
     }
@@ -47,6 +45,7 @@
 In your .conf:
 
     <Controller::Foo>
+        cgi_root_path cgi-bin
         <CGI>
             username_field username # used for REMOTE_USER env var
             pass_env PERL5LIB
@@ -69,6 +68,8 @@
 
 =cut
 
+has cgi_root_path => (is => 'ro', isa => 'Str', default => 'cgi-bin');
+
 sub register_actions {
     my ($self, $app) = @_;
 
@@ -160,13 +161,17 @@
 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.
 
-The default is C<cgi-bin/$cgi>.
+The default is to prefix with the C<cgi_root_path> config setting, or if not set
+uses C<cgi-bin/$cgi>.
 
 =cut
 
 sub cgi_path {
     my ($self, $cgi) = @_;
-    return "cgi-bin/$cgi";
+
+    my $root = $self->cgi_root_path;
+    $root =~ s{/*$}{};
+    return "$root/$cgi";
 }
 
 =head2 $self->is_perl_cgi($path)

Modified: trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm	2009-04-26 19:52:52 UTC (rev 9862)
+++ trunk/Catalyst-Controller-WrapCGI/lib/Catalyst/Controller/WrapCGI.pm	2009-04-26 20:56:27 UTC (rev 9863)
@@ -1,9 +1,10 @@
 package Catalyst::Controller::WrapCGI;
 
-use strict;
-use warnings;
-use parent 'Catalyst::Controller';
+use Moose;
+use mro 'c3';
 
+extends 'Catalyst::Controller';
+
 use HTTP::Request::AsCGI;
 use HTTP::Request;
 use URI;

Added: trunk/Catalyst-Controller-WrapCGI/t/cgibin_root.t
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/cgibin_root.t	                        (rev 0)
+++ trunk/Catalyst-Controller-WrapCGI/t/cgibin_root.t	2009-04-26 20:56:27 UTC (rev 9863)
@@ -0,0 +1,21 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin '$Bin';
+use lib "$Bin/lib";
+
+use Test::More tests => 1;
+
+use Catalyst::Test 'TestCGIBinRoot';
+use HTTP::Request::Common;
+
+# test default root of "cgi-bin"
+
+my $response = request POST '/cgi-bin/path/test.pl', [
+    foo => 'bar',
+    bar => 'baz'
+];
+
+is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File');

Modified: trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm	2009-04-26 19:52:52 UTC (rev 9862)
+++ trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBin/Controller/CGIHandler.pm	2009-04-26 20:56:27 UTC (rev 9863)
@@ -2,6 +2,13 @@
 
 use parent 'Catalyst::Controller::CGIBin';
 
+# Turn off log for the non-zero exit test
+sub auto : Private {
+    my ($self, $c) = @_;
+    $c->log->levels() unless $c->debug;
+    1;
+}
+
 sub cgi_path {
     my ($self, $cgi) = @_;
     return "my-bin/$cgi";

Added: trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/Controller/CGIHandler.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/Controller/CGIHandler.pm	                        (rev 0)
+++ trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/Controller/CGIHandler.pm	2009-04-26 20:56:27 UTC (rev 9863)
@@ -0,0 +1,5 @@
+package TestCGIBinRoot::Controller::CGIHandler;
+
+use parent 'Catalyst::Controller::CGIBin';
+
+1;

Added: trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/path/test.pl
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/path/test.pl	                        (rev 0)
+++ trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/path/test.pl	2009-04-26 20:56:27 UTC (rev 9863)
@@ -0,0 +1,11 @@
+#!/usr/bin/perl 
+
+use strict;
+use warnings;
+
+use CGI ':standard';
+
+die '$ENV{MOD_PERL} must not be set' if $ENV{MOD_PERL};
+
+print header;
+print 'foo:',param('foo'),' bar:',param('bar')


Property changes on: trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot/root/cgi-bin/path/test.pl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot.pm
===================================================================
--- trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot.pm	                        (rev 0)
+++ trunk/Catalyst-Controller-WrapCGI/t/lib/TestCGIBinRoot.pm	2009-04-26 20:56:27 UTC (rev 9863)
@@ -0,0 +1,8 @@
+package TestCGIBinRoot;
+
+use Catalyst::Runtime '5.70';
+use parent 'Catalyst';
+
+__PACKAGE__->setup(qw/Static::Simple/);
+
+1;




More information about the Catalyst-commits mailing list