[Jifty-commit] r4732 - in jifty/trunk: lib/Jifty t/TestApp/lib/TestApp t/TestApp/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Dec 17 23:07:41 EST 2007


Author: falcone
Date: Mon Dec 17 23:07:26 2007
New Revision: 4732

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Dispatcher.pm
   jifty/trunk/t/TestApp/lib/TestApp/Dispatcher.pm
   jifty/trunk/t/TestApp/t/02-dispatch.t

Log:
 r27631 at ketch:  falcone | 2007-12-17 23:05:12 -0500
 * add a check for the op to the dispatcher condition cache
   because on and the other ops generate different regexps


Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm	Mon Dec 17 23:07:26 2007
@@ -985,7 +985,9 @@
     # Previously compiled (eg. a qr{} -- return it verbatim)
     return $cond if ref $cond;
 
-    unless ( $CONDITION_CACHE{$cond} ) {
+    my $cachekey = join('-', (($Dispatcher->{rule} eq 'on') ? 'on' : 'in'),
+                             $cond);
+    unless ( $CONDITION_CACHE{$cachekey} ) {
 
         my $compiled = $cond;
 
@@ -1027,9 +1029,9 @@
         if ( !$has_capture ) {
             $compiled = "($compiled)";
         }
-        $CONDITION_CACHE{$cond} = qr{$compiled};
+        $CONDITION_CACHE{$cachekey} = qr{$compiled};
     }
-    return $CONDITION_CACHE{$cond};
+    return $CONDITION_CACHE{$cachekey};
 }
 
 =head2 _compile_glob METAEXPRESSION

Modified: jifty/trunk/t/TestApp/lib/TestApp/Dispatcher.pm
==============================================================================
--- jifty/trunk/t/TestApp/lib/TestApp/Dispatcher.pm	(original)
+++ jifty/trunk/t/TestApp/lib/TestApp/Dispatcher.pm	Mon Dec 17 23:07:26 2007
@@ -1,6 +1,16 @@
 package TestApp::Dispatcher;
 use Jifty::Dispatcher -base;
 
+under '/' => run {
+}
+
+on '/' => run {
+    # shouldn't ever run because 02-dispatch.t doesn't request the root
+    # demonstrates bad interaction between under '/' and on '/' and 
+    # the condition cache in the dispatcher
+    set phantom => 99;
+}
+
 before '/redirect' => run {
     Jifty->web->request->add_action(
         moniker => 'thing',
@@ -9,8 +19,6 @@
     redirect '/index.html';
 };
 
-
-
 on '/dispatch/' => run {
     dispatch "/dispatch/basic";
 };
@@ -19,12 +27,12 @@
     dispatch "/dispatch/basic-show";
 };
 
-
 my $count = 0;
 my $before = 0;
 my $after = 0;
 my $after_once = 0;
 
+
 on '/dispatch/basic' => run {
     set count => $count++;
 };

Modified: jifty/trunk/t/TestApp/t/02-dispatch.t
==============================================================================
--- jifty/trunk/t/TestApp/t/02-dispatch.t	(original)
+++ jifty/trunk/t/TestApp/t/02-dispatch.t	Mon Dec 17 23:07:26 2007
@@ -4,7 +4,7 @@
 
 use lib 't/lib';
 use Jifty::SubTest;
-use Jifty::Test tests => 28;
+use Jifty::Test tests => 29;
 use Jifty::Test::WWW::Mechanize;
 
 my $server  = Jifty::Test->make_server;
@@ -20,6 +20,7 @@
 $mech->content_contains("before: 0");
 $mech->content_contains("after: 0");
 $mech->content_contains("after_once: 0");
+$mech->content_lacks("phantom: 99");
 
 $mech->get_ok("$URL/dispatch/basic-show", "Got /dispatch/basic-show");
 $mech->content_contains("Basic test with forced show.");


More information about the Jifty-commit mailing list