[Jifty-commit] r597 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Feb 18 16:17:32 EST 2006


Author: alexmv
Date: Sat Feb 18 16:17:31 2006
New Revision: 597

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

Log:
 r9160 at zoq-fot-pik:  chmrr | 2006-02-18 16:16:48 -0500
  * The _do_dispatch in handle_request needs to also catch the
 LAST_RULE exceptions, otherwise cleanup never gets run
  * _do_show's default path should be from the most recent dispatch,
 not from the request


Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm	Sat Feb 18 16:17:31 2006
@@ -412,7 +412,12 @@
 
     local $Dispatcher = $self->new();
 
-            $Dispatcher->_do_dispatch($path); 
+    eval {
+        $Dispatcher->_do_dispatch($path);
+    };
+    if ( my $err = $@ ) {
+        $self->log->warn(ref($err) . " " ."'$err'") if ( $err !~ /^LAST RULE/);
+    }
 }
 
 =head2 _handle_rules RULESET
@@ -624,7 +629,8 @@
 
     # Fix up the path
     $path = shift if (@_);
-    $path ||= request->path;
+    $path ||= $self->{path};
+    $self->log->debug("Showing path $path");
 
     # If we've got a working directory (from an "under" rule) and we have 
     # a relative path, prepend the working directory
@@ -640,7 +646,7 @@
     
     # 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 );
+      if $path !~ m{/$} and -d Jifty::Util->absolute_path( (Jifty->config->framework('Web')->{'TemplateRoot'} || "html") . $path );
     
     # Set the request path
     request->path($path);
@@ -702,18 +708,17 @@
 
     $self->log->debug("Dispatching request to ".$self->{path});
     eval {
-            $self->_handle_rules( [ $self->rules('SETUP') ] );
-            HANDLE_WEB: { Jifty->web->handle_request(); }
-            $self->_handle_rules( [ $self->rules('RUN'), 'show' ] );
-            $self->_handle_rules( [ $self->rules('CLEANUP') ] );
+        $self->_handle_rules( [ $self->rules('SETUP') ] );
+        HANDLE_WEB: { Jifty->web->handle_request(); }
+        $self->_handle_rules( [ $self->rules('RUN'), 'show' ] );
+        $self->_handle_rules( [ $self->rules('CLEANUP') ] );
     };
     if ( my $err = $@ ) {
-        warn ref($err) . " " ."'$err'" if ( $err !~ /^LAST RULE/);
+        $self->log->warn(ref($err) . " " ."'$err'") if ( $err !~ /^LAST RULE/);
     }
     last_rule;
 }
 
-
 =head2 _match CONDITION
 
 Returns the regular expression matched if the current request fits


More information about the Jifty-commit mailing list