[Jifty-commit] r529 -

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jan 27 14:47:45 EST 2006


Author: jesse
Date: Fri Jan 27 14:47:44 2006
New Revision: 529

Modified:
   /   (props changed)
   jifty/trunk/lib/Jifty/Action.pm
   jifty/trunk/lib/Jifty/Dispatcher.pm
   jifty/trunk/lib/Jifty/Web.pm

Log:
 r23008 at truegrounds:  jesse | 2006-01-27 20:43:36 +0100
 * Added a bunch of debug logging


Modified: jifty/trunk/lib/Jifty/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Action.pm	Fri Jan 27 14:47:44 2006
@@ -145,7 +145,9 @@
 
 sub run {
     my $self = shift;
+    $self->log->debug("Running action");
     return unless $self->result->success;
+    $self->log->debug("Taking action");
     $self->take_action;
     $self->cleanup;
 }
@@ -601,6 +603,7 @@
     $self->_validate_argument($_)
       for $self->argument_names;
 
+
     return $self->result->success;
 }
 
@@ -623,6 +626,9 @@
     my $field = shift;
 
     return unless $field;
+    
+    $self->log->debug(" validating argument $field");
+
     my $field_info = $self->arguments->{$field};
     return unless $field_info;
 

Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm	Fri Jan 27 14:47:44 2006
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 use Exporter;
-use base 'Exporter';
+use base qw/Exporter Jifty::Object/;
            
 
 =head1 NAME
@@ -398,7 +398,8 @@
     my $self = shift;
 
     my $path = Jifty->web->request->path;
-    $path =~ s{/index\.html$}{};
+    # XXX TODO: jesse commented this out because it weirdly breaks things
+    #    $path =~ s{/index\.html$}{};
 
     local $Dispatcher = $self->new();
 
@@ -518,6 +519,7 @@
     my ( $self, $cond, $rules ) = @_;
     if ( my $regex = $self->_match($cond) ) {
 
+        $self->log->debug("Matched 'before' rule $regex for ".$self->{'path'});
         # match again to establish $1 $2 etc in the dynamic scope
         $self->{path} =~ $regex;
         $self->_handle_rules($rules);
@@ -535,6 +537,7 @@
     my ( $self, $cond, $rules ) = @_;
     if ( my $regex = $self->_match($cond) ) {
 
+        $self->log->debug("Matched 'on' rule $regex for ".$self->{'path'});
         # match again to establish $1 $2 etc in the dynamic scope
         $self->{path} =~ $regex;
         $self->_handle_rules($rules);
@@ -550,7 +553,7 @@
 sub _do_after {
     my ( $self, $cond, $rules ) = @_;
     if ( my $regex = $self->_match($cond) ) {
-
+        $self->log->debug("Matched 'on' rule $regex for ".$self->{'path'});
         # match again to establish $1 $2 etc in the dynamic scope
         $self->{path} =~ $regex;
         $self->_handle_rules($rules);
@@ -579,6 +582,7 @@
 
 sub _do_redirect {
     my ( $self, $path ) = @_;
+    $self->log->debug("Redirecting to $path");
     Jifty->web->redirect($path);
     last_rule;
 }
@@ -593,6 +597,7 @@
 
 sub _do_abort {
     my $self = shift;
+    $self->log->debug("Aborting processing");
     last_rule;
 }
 
@@ -612,40 +617,54 @@
     # Fix up the path
     $path = shift if (@_);
     $path ||= request->path;
+
+    # If we've got a working directory (from an "under" rule) and we have 
+    # a relative path, prepend the working directory
     $path = "$self->{cwd}/$path" unless $path =~ m{^/};
-    $path .= "index.html" if $path =~ m{/$};
 
-    # Redirect to directory (and then index) if they requested the directory itself
+    # If we're requesting a directory, go looking for the index.html
+    if ($path =~ m{/$} and 
+        Jifty->handler->mason->interp->comp_exists($path."/index.html")) {
+         $path .= "index.html" 
+    }
+    # Redirect to directory (and then index) if they requested 
+    # the directory itself
+    
+    # XXX TODO, we should search all component roots
     $self->_do_redirect($path . "/") 
       if -d Jifty::Util->absolute_path( (Jifty->config->framework('Web')->{'TemplateRoot'} || "html") . $path );
     
     # Set the request path
     request->path($path);
 
-    # Handle the request with Mason
+    $self->log->debug("Having Mason handle ".request->path);
     eval { Jifty->handler->mason->handle_comp(request->path); };
-
+    my $err = $@;
     # Handle parse errors
-    if ( $@ and not UNIVERSAL::isa $@, 'HTML::Mason::Exception::Abort' ) {
-        warn "Mason error: $@";
+    if ( $err and not UNIVERSAL::isa $err, 'HTML::Mason::Exception::Abort' ) {
+        warn "Mason error: $err";
         Jifty->web->redirect("/__jifty/error/mason_parse_error");
-    };
+    } elsif ($err) {
+        die $err;
+    }
     last_rule;
 }
 
 sub _do_set {
     my ( $self, $key, $value ) = @_;
-
+    $self->log->debug("Setting argument $key to $value");
     request->argument($key, $value);
 }
 
 sub _do_del {
     my ( $self, $key ) = @_;
+    $self->log->debug("Deleting argument $key");
     request->delete($key);
 }
 
 sub _do_default {
     my ( $self, $key, $value ) = @_;
+    $self->log->debug("Setting argument default $key to $value");
     request->argument($key, $value)
         unless defined request->argument($key);
 }
@@ -672,6 +691,7 @@
     $self->{path} =~ s{/+}{/}g;
     $self->{path} =~ s{/$}{};
 
+    $self->log->debug("Dispatching request to ".$self->{path});
     eval {
         HANDLER: {
             $self->_handle_rules( [ $self->rules('SETUP') ] );
@@ -763,6 +783,7 @@
 
 sub _match_method {
     my ( $self, $method ) = @_;
+    $self->log->debug("Matching URL ".$self->{cgi}->method." against ".$method);
     lc( $self->{cgi}->method ) eq lc($method);
 }
 

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Fri Jan 27 14:47:44 2006
@@ -210,12 +210,12 @@
 sub handle_request {
     my $self = shift;
     die "No request to handle" unless Jifty->web->request;
-    
     Jifty->web->response( Jifty::Response->new ) unless $self->response;
     Jifty->web->setup_session;
 
     my @valid_actions;
             for my $request_action ( $self->request->actions ) {
+        $self->log->debug("Found action ".$request_action->class . " " . $request_action->moniker);
         next unless $request_action->active;
         unless ( $self->is_allowed( $request_action->class ) ) {
             $self->log->warn( "Attempt to call denied action '"
@@ -249,7 +249,13 @@
             # Try validating again
             $action->result(Jifty::Result->new);
             $self->response->result( $action->moniker => $action->result );
-            eval { $action->run if $action->validate; };
+            eval {
+                $self->log->debug("Validating action ".ref($action). " ".$action->moniker);
+                if ($action->validate) { 
+                    $self->log->debug("Running action.");
+                    $action->run 
+                }
+            };
             if ( my $err = $@ ) {
                 $self->log->fatal($err);
             }


More information about the Jifty-commit mailing list