[Jifty-commit] r691 - jifty/trunk/lib/Jifty
jifty/trunk/lib/Jifty/Action jifty/trunk/lib/Jifty/Action/Record
jifty/trunk/lib/Jifty/Mason jifty/trunk/lib/Jifty/Script
jifty/trunk/share/web/templates/__jifty/admin
jifty/trunk/share/web/templates/__jifty/admin/_elements
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Mar 15 18:07:15 EST 2006
Author: jesse
Date: Wed Mar 15 18:07:05 2006
New Revision: 691
Modified:
/ (props changed)
jifty/trunk/lib/Jifty/Action.pm
jifty/trunk/lib/Jifty/Action/Record.pm
jifty/trunk/lib/Jifty/Action/Record/Update.pm
jifty/trunk/lib/Jifty/Dispatcher.pm
jifty/trunk/lib/Jifty/Mason/Halo.pm
jifty/trunk/lib/Jifty/Model/Schema.pm
jifty/trunk/lib/Jifty/Object.pm
jifty/trunk/lib/Jifty/Record.pm
jifty/trunk/lib/Jifty/RightsFrom.pm
jifty/trunk/lib/Jifty/Script/Schema.pm
jifty/trunk/lib/Jifty/Server.pm
jifty/trunk/share/web/templates/__jifty/admin/_elements/nav
jifty/trunk/share/web/templates/__jifty/admin/index.html
Log:
r26292 at truegrounds: jesse | 2006-03-15 14:50:38 -0500
* chromatic supplied a patch to switch from UNIVERSAL::isa to ->isa.
* Fixed some nits turned up by internal testing.
Modified: jifty/trunk/lib/Jifty/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action.pm (original)
+++ jifty/trunk/lib/Jifty/Action.pm Wed Mar 15 18:07:05 2006
@@ -566,7 +566,7 @@
my $default_method = 'canonicalize_' . $field;
if ( $field_info->{canonicalizer}
- and UNIVERSAL::isa( $field_info->{canonicalizer}, 'CODE' ) )
+ and defined &{ $field_info->{canonicalizer} } )
{
$value = $field_info->{canonicalizer}->( $self, $value );
}
@@ -651,7 +651,7 @@
# Finally, fall back to running a validator sub
if ( $field_info->{validator}
- and UNIVERSAL::isa( $field_info->{validator}, 'CODE' ) )
+ and defined &{ $field_info->{validator} } )
{
return $field_info->{validator}->( $self, $value );
}
Modified: jifty/trunk/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record.pm (original)
+++ jifty/trunk/lib/Jifty/Action/Record.pm Wed Mar 15 18:07:05 2006
@@ -69,7 +69,7 @@
if (ref $record_class) {
$self->record($record_class);
$self->argument_value($_, $self->record->$_) for @{ $self->record->_primary_keys };
- } elsif (UNIVERSAL::isa($args{record}, $record_class)) {
+ } elsif (ref $args{record} and $args{record}->isa($record_class)) {
$self->record($args{record});
$self->argument_value($_, $self->record->$_) for @{ $self->record->_primary_keys };
} else {
@@ -116,7 +116,7 @@
# If the current value is actually a pointer to another object, dereference it
$current_value = $current_value->id
- if UNIVERSAL::isa( $current_value, 'Jifty::Record' );
+ if ref($current_value) and $current_value->isa( 'Jifty::Record' );
$info->{default_value} = $current_value if $self->record->id;
}
@@ -142,11 +142,11 @@
}
elsif ( defined $column->refers_to ) {
- my $ref = $column->refers_to;
- if ( UNIVERSAL::isa( $ref, 'Jifty::Record' ) ) {
+ my $refers_to = $column->refers_to;
+ if ( ref($refers_to) and $refers_to->isa( 'Jifty::Record' ) ) {
my $collection = Jifty::Collection->new(
- record_class => $ref,
+ record_class => $refers_to,
current_user => $self->record->current_user
);
$collection->unlimit;
Modified: jifty/trunk/lib/Jifty/Action/Record/Update.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record/Update.pm (original)
+++ jifty/trunk/lib/Jifty/Action/Record/Update.pm Wed Mar 15 18:07:05 2006
@@ -91,7 +91,8 @@
# Skip fields that have not changed
my $old = $self->record->$field;
- $old = $old->id if UNIVERSAL::isa( $old, "Jifty::Record" );
+ # XXX TODO: This ignore "by" on columns
+ $old = $old->id if ref($old) and $old->isa( 'Jifty::Record' );
# if both the new and old values are defined and equal, we don't want to change em
# XXX TODO "$old" is a cheap hack to scalarize datetime objects
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Wed Mar 15 18:07:05 2006
@@ -683,7 +683,7 @@
eval { Jifty->handler->mason->handle_comp(request->path); };
my $err = $@;
# Handle parse errors
- if ( $err and not UNIVERSAL::isa $err, 'HTML::Mason::Exception::Abort' ) {
+ if ( $err and not eval { $err->isa( 'HTML::Mason::Exception::Abort' ) } ) {
# XXX TODO: get this into the browser somehow
warn "Mason error: $err";
Jifty->web->redirect("/__jifty/error/mason_internal_error");
Modified: jifty/trunk/lib/Jifty/Mason/Halo.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Mason/Halo.pm (original)
+++ jifty/trunk/lib/Jifty/Mason/Halo.pm Wed Mar 15 18:07:05 2006
@@ -45,7 +45,7 @@
push @$STACK, {
id => $halo_base,
- args => [map {UNIVERSAL::isa($_,"GLOB") ? "*GLOB*" : $_} @{$context->args}],
+ args => [map { eval { fileno( $_ ) } ? "*GLOB*" : $_} @{$context->args}],
start_time => Time::HiRes::time(),
path => $context->comp->path,
subcomponent => ( $context->comp->is_subcomp() ? 1:0),
Modified: jifty/trunk/lib/Jifty/Model/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Model/Schema.pm (original)
+++ jifty/trunk/lib/Jifty/Model/Schema.pm Wed Mar 15 18:07:05 2006
@@ -79,7 +79,7 @@
my $self = shift;
my $ver = shift;
- unless (UNIVERSAL::isa($ver, "version")) {
+ unless ( eval { $ver->isa( 'version' ) } ) {
$self->log->fatal("Version must be a version object");
return;
}
Modified: jifty/trunk/lib/Jifty/Object.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Object.pm (original)
+++ jifty/trunk/lib/Jifty/Object.pm Wed Mar 15 18:07:05 2006
@@ -79,7 +79,7 @@
my $caller_self = $DB::args[0];
next unless (ref($caller_self)); #skip class methods;
next if ($caller_self eq $self);
- next unless UNIVERSAL::can($caller_self => 'current_user');
+ next unless $caller_self->can('current_user');
eval {
if ( $caller_self->current_user and $caller_self->current_user->id) {
Modified: jifty/trunk/lib/Jifty/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Record.pm (original)
+++ jifty/trunk/lib/Jifty/Record.pm Wed Mar 15 18:07:05 2006
@@ -165,7 +165,7 @@
return $self->delegate_current_user_can($right, @_);
}
- unless ( UNIVERSAL::isa( $self->current_user, 'Jifty::CurrentUser' ) ) {
+ unless ( $self->current_user->isa( 'Jifty::CurrentUser' ) ) {
$self->log->error(
"Hm. called to authenticate without a currentuser - "
. $self->current_user );
@@ -260,7 +260,7 @@
my $classname = $column->refers_to();
return undef unless $classname;
- return unless UNIVERSAL::isa( $classname, 'Jifty::DBI::Collection' );
+ return unless $classname->isa( 'Jifty::DBI::Collection' );
my $coll = $classname->new( current_user => $self->current_user );
@@ -302,7 +302,7 @@
return unless defined $value;
return undef unless $classname;
- return unless UNIVERSAL::isa( $classname, 'Jifty::Record' );
+ return unless $classname->isa( 'Jifty::Record' );
# XXX TODO FIXME we need to figure out the right way to call new here
# perhaps the handle should have an initiializer for records/collections
Modified: jifty/trunk/lib/Jifty/RightsFrom.pm
==============================================================================
--- jifty/trunk/lib/Jifty/RightsFrom.pm (original)
+++ jifty/trunk/lib/Jifty/RightsFrom.pm Wed Mar 15 18:07:05 2006
@@ -98,29 +98,34 @@
=cut
sub delegate_current_user_can {
- my $self = shift;
- my $object_type = shift; #always 'column' for now
- my $col_name = shift;
- my $right = shift;
- my %attribs = @_;
+ my $self = shift;
+ my $object_type = shift; #always 'column' for now
+ my $col_name = shift;
+ my $right = shift;
+ my %attribs = @_;
$right = 'update' if $right ne 'read';
my $obj;
my $column = $self->column($col_name);
my $obj_type = $column->refers_to();
+ # XXX TODO: this card is bloody hard to follow. it's my fault. --jesse
- if ( UNIVERSAL::isa( $attribs{ $column->name }, $obj_type ) ) {
- $obj = $attribs{ $column->name };
- } elsif ( $attribs{ $column->name }
- || $self->__value( $column->name )
- || $self->{ $column->name } )
+ my $foreign_key = $attribs{ $column->name };
+ # We only do the isa if the foreign_key is a reference
+ # We could also do this using eval, but it's an order of magnitude slower
+ if ( ref($foreign_key) and $foreign_key->isa($obj_type) ) {
+ $obj = $foreign_key; # the fk is actually an object
+ } elsif (
+ my $fk_value = (
+ $foreign_key
+ || $self->__value( $column->name )
+ || $self->{ $column->name }
+ )
+ )
{
$obj = $obj_type->new( current_user => $self->current_user );
- $obj->load_by_cols(
- ( $column->by || 'id' ) => $attribs{ $column->name }
- || $self->__value( $column->name )
- || $self->{ $column->name } );
+ $obj->load_by_cols( ( $column->by || 'id' ) => $fk_value );
} else {
return 0;
}
Modified: jifty/trunk/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Schema.pm (original)
+++ jifty/trunk/lib/Jifty/Script/Schema.pm Wed Mar 15 18:07:05 2006
@@ -195,9 +195,9 @@
# TODO XXX FIXME:
# This *will* try to generate SQL for abstract base classes you might
# stick in $AC::Model::.
- next if not UNIVERSAL::isa( $model, 'Jifty::Record' );
+ next unless $model->isa( 'Jifty::Record' );
do { log->info("Skipping $model"); next }
- if ( UNIVERSAL::can( $model, 'since' )
+ if ( $model->can( 'since' )
and $appv < $model->since );
$log->info("Using $model");
@@ -228,7 +228,7 @@
Jifty::Util->require($bootstrapper);
$bootstrapper->run()
- if ( UNIVERSAL::can( $bootstrapper => 'run' ) );
+ if $bootstrapper->can( 'run' );
};
die $@ if $@;
@@ -283,8 +283,7 @@
for my $model ( __PACKAGE__->models ) {
# We don't want to get the Collections, for example.
- do {next}
- unless UNIVERSAL::isa( $model, 'Jifty::Record' );
+ do {next} unless $model->isa( 'Jifty::Record' );
# Set us up the table
$model = $model->new;
@@ -292,7 +291,7 @@
->_db_schema_table_from_model($model);
# If this whole table is new
- if ( UNIVERSAL::can( $model, "since" )
+ if ( $model->can( 'since' )
and $appv >= $model->since
and $dbv < $model->since )
{
Modified: jifty/trunk/lib/Jifty/Server.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Server.pm (original)
+++ jifty/trunk/lib/Jifty/Server.pm Wed Mar 15 18:07:05 2006
@@ -124,7 +124,7 @@
sub recording_on {
my $class = shift;
our @ISA;
- unshift @ISA, "HTTP::Server::Simple::Recorder" unless UNIVERSAL::isa($class, 'HTTP::Server::Simple::Recorder');
+ unshift @ISA, "HTTP::Server::Simple::Recorder" unless $class->isa('HTTP::Server::Simple::Recorder');
}
1;
Modified: jifty/trunk/share/web/templates/__jifty/admin/_elements/nav
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/admin/_elements/nav (original)
+++ jifty/trunk/share/web/templates/__jifty/admin/_elements/nav Wed Mar 15 18:07:05 2006
@@ -22,7 +22,7 @@
# TODO XXX FIXME:
# This *will* try to generate SQL for abstract base classes you might
# stick in $AC::Model::.
- next if not UNIVERSAL::isa( $model, 'Jifty::Record' );
+ next unless $model->isa( 'Jifty::Record' );
next if $model =~ /::SUPER$/;
push @models, $model;
}
Modified: jifty/trunk/share/web/templates/__jifty/admin/index.html
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/admin/index.html (original)
+++ jifty/trunk/share/web/templates/__jifty/admin/index.html Wed Mar 15 18:07:05 2006
@@ -22,7 +22,7 @@
# TODO XXX FIXME:
# This *will* try to generate SQL for abstract base classes you might
# stick in $AC::Model::.
- next if not UNIVERSAL::isa( $model, 'Jifty::Record' );
+ next unless $model->isa( 'Jifty::Record' );
next if $model =~ /::SUPER$/;
push @models, $model;
}
More information about the Jifty-commit
mailing list