[Jifty-commit] r683 - in jifty/trunk: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Mar 9 19:22:50 EST 2006
Author: alexmv
Date: Thu Mar 9 19:22:49 2006
New Revision: 683
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Dispatcher.pm
jifty/trunk/lib/Jifty/Util.pm
Log:
r8475 at zoq-fot-pik: chmrr | 2006-03-09 19:22:42 -0500
* Leaving off the '1;' in a Dispatcher silently ate the last rule
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Thu Mar 9 19:22:49 2006
@@ -323,21 +323,24 @@
} elsif ( defined wantarray ) {
[ [ $op => splice( @_, 0, length($proto) ) ], @_ ];
} else {
- my $ruleset;
- if ( $op eq 'before' ) {
- $ruleset = 'RULES_SETUP';
- } elsif ( $op eq 'after' ) {
- $ruleset = 'RULES_CLEANUP';
- } else {
- $ruleset = 'RULES_RUN';
- }
-
- no strict 'refs';
+ _push_rule($pkg, [ $op => splice( @_, 0, length($proto) ) ] );
+ }
+}
- # XXX TODO, need to spec stage here.
- push @{ $pkg . '::' . $ruleset },
- [ $op => splice( @_, 0, length($proto) ) ], @_;
+sub _push_rule($$) {
+ my($pkg, $rule) = @_;
+ my $op = $rule->[0];
+ my $ruleset;
+ if ( $op eq 'before' ) {
+ $ruleset = 'RULES_SETUP';
+ } elsif ( $op eq 'after' ) {
+ $ruleset = 'RULES_CLEANUP';
+ } else {
+ $ruleset = 'RULES_RUN';
}
+ no strict 'refs';
+ # XXX TODO, need to spec stage here.
+ push @{ $pkg . '::' . $ruleset }, $rule;
}
sub _qualify ($@) {
Modified: jifty/trunk/lib/Jifty/Util.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Util.pm (original)
+++ jifty/trunk/lib/Jifty/Util.pm Thu Mar 9 19:22:49 2006
@@ -12,6 +12,7 @@
=cut
+use Jifty;
use File::Spec;
use File::ShareDir;
use UNIVERSAL::require;
@@ -164,14 +165,22 @@
my $class = shift;
my $path = join('/', split(/::/,$class)).".pm";
- return 1 if $INC{$path};
- $class->require;
+ return 1 if $INC{$path};
+
+ my $retval = $class->require;
if ($UNIVERSAL::require::ERROR) {
my $error = $UNIVERSAL::require::ERROR;
$error =~ s/ at .*?\n$//;
Jifty->log->error(sprintf("$error at %s line %d\n", (caller)[1,2]));
return 0;
}
+
+ # If people forget the '1;' line in the dispatcher, don't eit them
+ if ($class =~ /::Dispatcher$/ and ref $retval eq "ARRAY") {
+ Jifty->log->error("$class did not return a true value; assuming it was a dispatcher rule");
+ Jifty::Dispatcher::_push_rule($class, $_) for @{$retval};
+ }
+
return 1;
}
More information about the Jifty-commit
mailing list