[Jifty-commit] r2378 - in jifty/trunk: lib/Jifty lib/Jifty/Action
lib/Jifty/Plugin
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Dec 11 18:46:01 EST 2006
Author: jesse
Date: Mon Dec 11 18:46:00 2006
New Revision: 2378
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Action/Record.pm
jifty/trunk/lib/Jifty/ClassLoader.pm
jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm
Log:
r46114 at pinglin: jesse | 2006-12-11 18:41:13 -0500
* Duplicate code removed from the plugin classloader
Modified: jifty/trunk/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record.pm (original)
+++ jifty/trunk/lib/Jifty/Action/Record.pm Mon Dec 11 18:46:00 2006
@@ -131,7 +131,6 @@
return $self->_cached_arguments if $self->_cached_arguments;
-
my $field_info = {};
my @fields = $self->possible_fields;
Modified: jifty/trunk/lib/Jifty/ClassLoader.pm
==============================================================================
--- jifty/trunk/lib/Jifty/ClassLoader.pm (original)
+++ jifty/trunk/lib/Jifty/ClassLoader.pm Mon Dec 11 18:46:00 2006
@@ -155,6 +155,7 @@
. "1;" );
} elsif ( $module =~ m!^(?:$base)::Action::(Create|Update|Delete|Search)([^\.]+)$! ) {
my $modelclass = $base . "::Model::" . $2;
+
Jifty::Util->require($modelclass);
return undef unless eval { $modelclass->table };
@@ -179,6 +180,8 @@
sub return_class {
my $self = shift;
my $content = shift;
+
+
open my $fh, '<', \$content;
return $fh;
Modified: jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm Mon Dec 11 18:46:00 2006
@@ -104,6 +104,8 @@
my $plugin = $self->{plugin};
return undef unless ( $module and $base and $plugin);
+
+
# Canonicalize $module to :: style rather than / and .pm style;
$module =~ s/.pm$//;
$module =~ s{/}{::}g;
@@ -116,7 +118,7 @@
# this is a class the plugin intends to autocreate
if ( $module =~ m{^(?:$base)::(Notification|CurrentUser)$} ) {
my $method = "${plugin}::$1";
- return $self->return_class(
+ return Jifty::ClassLoader->return_class(
"use warnings; use strict; package $module;\n"
. "use base qw/$method/;\n"
. "sub _autogenerated { 1 };\n"
@@ -127,14 +129,14 @@
my $method = $1;
# Check to see if this is an action for a model that this plugin
- # doesn't support
+ # doesn't provide
if ( $method =~ m/^(?:Create|Update|Delete)([^\.]+)$/ ) {
my $model = "${plugin}::Model::$1";
return undef unless Jifty::Util->already_required($model);
}
$method = "${plugin}::Action::$method";
- return $self->return_class(
+ return Jifty::ClassLoader->return_class(
"use warnings; use strict; package $module;\n"
. "use base qw/$method/;\n"
. "sub autogenerated { 1 };\n"
@@ -145,21 +147,6 @@
return undef;
}
-=head2 return_class CODE
-
-A helper method; takes CODE as a string and returns an open filehandle
-containing that CODE.
-
-=cut
-
-sub return_class {
- my $self = shift;
- my $content = shift;
- open my $fh, '<', \$content;
- return $fh;
-
-}
-
=head2 require
Loads all of the application's Actions and Models. It additionally
@@ -174,6 +161,7 @@
my $base = $self->{plugin};
+
# if we don't even have an application class, this trick will not work
return unless ($base);
Jifty::Util->require($base);
More information about the Jifty-commit
mailing list