Minor performance tweaks, added $c->request->user
Christian Hansen [Tue, 17 May 2005 14:28:32 +0000 (14:28 +0000)]
Changes
lib/Catalyst/Engine.pm
lib/Catalyst/Engine/Apache/Base.pm
lib/Catalyst/Engine/Apache/MP13/APR.pm
lib/Catalyst/Engine/CGI.pm
lib/Catalyst/Engine/CGI/Base.pm
lib/Catalyst/Request.pm

diff --git a/Changes b/Changes
index 2e7455c..f50848f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,7 +2,7 @@ This file documents the revision history for Perl extension Catalyst.
 
 5.20  Sun Apr 24 17:00:00 2005
         - improved uploads and parameters
-        - added $c->req->protocol and $c->req->secure
+        - added $c->req->protocol, $c->req->secure and $c->req->user
         - improved error message when forwarding to unknown module
         - fixed win32 installer
         - added deep recursion detection
index 0aeefac..b0b84d9 100644 (file)
@@ -623,35 +623,6 @@ Prepare uploads.
 
 sub prepare_uploads { }
 
-=item $c->retrieve_components
-
-Retrieve Components.
-
-=cut
-
-sub retrieve_components {
-    my $self = shift;
-
-    my $class = ref $self || $self;
-    eval <<"";
-        package $class;
-        import Module::Pluggable::Fast
-          name    => '_components',
-          search  => [
-            '$class\::Controller', '$class\::C',
-            '$class\::Model',      '$class\::M',
-            '$class\::View',       '$class\::V'
-          ],
-          require => 1;
-
-    if ( my $error = $@ ) {
-        chomp $error;
-        die qq/Couldn't load components "$error"/;
-    }
-
-    return $self->_components;
-}
-
 =item $c->run
 
 Starts the engine.
@@ -701,7 +672,7 @@ Setup components.
 
 sub setup_components {
     my $self = shift;
-
+    
     # Components
     my $class = ref $self || $self;
     eval <<"";
index bcf8458..d40f050 100644 (file)
@@ -75,7 +75,8 @@ sub prepare_connection {
     $c->request->address( $c->apache->connection->remote_ip );
     $c->request->hostname( $c->apache->connection->remote_host );
     $c->request->protocol( $c->apache->protocol );
-    
+    $c->request->user( $c->apache->user );
+
     if ( $ENV{HTTPS} || $c->apache->get_server_port == 443 ) {
         $c->request->secure(1);
     }
index d978f9c..1867b1b 100644 (file)
@@ -23,16 +23,6 @@ This class overloads some methods from C<Catalyst::Engine::Apache::MP13::Base>.
 
 =over 4
 
-=item $c->prepare_request($r)
-
-=cut
-
-sub prepare_request {
-    my ( $c, $r ) = @_;
-    $c->apache( Apache::Request->new($r) );
-}
-
-
 =item $c->prepare_parameters
 
 =cut
@@ -51,6 +41,15 @@ sub prepare_parameters {
     $c->request->param(@params);
 }
 
+=item $c->prepare_request($r)
+
+=cut
+
+sub prepare_request {
+    my ( $c, $r ) = @_;
+    $c->apache( Apache::Request->new($r) );
+}
+
 =item $c->prepare_uploads
 
 =cut
index 1a8f37c..409ce5a 100644 (file)
@@ -5,6 +5,22 @@ use base 'Catalyst::Engine::CGI::Base';
 
 use CGI;
 
+our @compile = qw[
+    delete
+    http
+    new_MultipartBuffer
+    param
+    parse_keywordlist
+    read_from_client
+    read_multipart
+    tmpFileName
+    uploadInfo
+    url_param
+    user_agent
+];
+
+CGI->compile(@compile);
+
 __PACKAGE__->mk_accessors('cgi');
 
 =head1 NAME
@@ -29,15 +45,7 @@ appropriate engine module.
 =head1 DESCRIPTION
 
 This is the Catalyst engine specialized for the CGI environment (using the
-C<CGI> and C<CGI::Cookie> modules).  Normally Catalyst will select the
-appropriate engine according to the environment that it detects, however you
-can force Catalyst to use the CGI engine by specifying the following in your
-application module:
-
-    use Catalyst qw(-Engine=CGI);
-
-The performance of this way of using Catalyst is not expected to be
-useful in production applications, but it may be helpful for development.
+C<CGI> and C<CGI::Cookie> modules).
 
 =head1 METHODS
 
index a76537b..8db3fe6 100644 (file)
@@ -69,6 +69,7 @@ sub prepare_connection {
     $c->request->address( $ENV{REMOTE_ADDR} );
     $c->request->hostname( $ENV{REMOTE_HOST} );
     $c->request->protocol( $ENV{SERVER_PROTOCOL} );
+    $c->request->user( $ENV{REMOTE_USER} );
 
     if ( $ENV{HTTPS} || $ENV{SERVER_PORT} == 443 ) {
         $c->request->secure(1);
index 8f96505..4e5ea1b 100644 (file)
@@ -5,7 +5,7 @@ use base 'Class::Accessor::Fast';
 
 __PACKAGE__->mk_accessors(
     qw/action address arguments body base cookies headers hostname match
-      method parameters path protocol secure snippets uploads/
+      method parameters path protocol secure snippets uploads user/
 );
 
 *args   = \&arguments;
@@ -53,7 +53,8 @@ Catalyst::Request - Catalyst Request Class
     $req->snippets;
     $req->upload;
     $req->uploads;
-    $req->user_agent
+    $req->user;
+    $req->user_agent;
 
 See also L<Catalyst>.
 
@@ -308,6 +309,10 @@ hashref or a arrayref containing C<Catalyst::Request::Upload> objects.
     my $upload = $c->request->uploads->{field};
     my $upload = $c->request->uploads->{field}->[0];
 
+=item $req->user
+
+Contains the user name of user if authentication check was successful.
+
 =item $req->user_agent
 
 Shortcut to $req->headers->user_agent. User Agent version string.