[Jifty-commit] r2454 - in jifty/trunk: lib/Jifty/Plugin
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Jan 3 12:32:02 EST 2007
Author: jpeacock
Date: Wed Jan 3 12:31:57 2007
New Revision: 2454
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm
Log:
r2107 at jfphome: jpeacock | 2007-01-02 20:37:12 -0500
Better handling of autocreated modules from plugins.
Print debug statements when autogenerating packages.
Modified: jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/ClassLoader.pm Wed Jan 3 12:31:57 2007
@@ -116,32 +116,53 @@
# Note that at this point, all of the plugins classes will already be
# loaded, so we can just check their presence when deciding whether
# this is a class the plugin intends to autocreate
- if ( $module =~ m{^(?:$base)::(Notification|CurrentUser)$} ) {
- my $method = "${plugin}::$1";
- return Jifty::ClassLoader->return_class(
+ if ( $module =~ m{^(?:$base)::CurrentUser$} ) {
+ my $method = "${plugin}::CurrentUser";
+ if ( Jifty::Util->already_required($method) ) {
+ Jifty->log->debug("Implementing $module using $method");
+ return Jifty::ClassLoader->return_class(
"use warnings; use strict; package $module;\n"
. "use base qw/$method/;\n"
. "sub _autogenerated { 1 };\n"
. "1;" )
- if Jifty::Util->already_required($method);
- }
- elsif ( $module =~ m{^(?:$base)::Action::([^\.]+)$} ) {
- my $method = $1;
+ }
+ else {
+ Jifty->log->debug("Couldn't implement $module using $method");
+ }
+ } elsif ( $module =~ m!^(?:$base)::Action::(Create|Update|Delete|Search)([^\.]+)$! ) {
+ my $model = "::Model::" . $2;
+ my $method = $plugin . "::Action::" . $1 . $2;
# Check to see if this is an action for a model that this plugin
# doesn't provide
- if ( $method =~ m/^(?:Create|Update|Delete)([^\.]+)$/ ) {
- my $model = "${plugin}::Model::$1";
- return undef unless Jifty::Util->already_required($model);
- }
+ return undef unless Jifty::Util->already_required("$plugin$model");
- $method = "${plugin}::Action::$method";
- return Jifty::ClassLoader->return_class(
+ if ( Jifty::Util->already_required($method) ) {
+ Jifty->log->debug("Implementing $module using $method");
+ return Jifty::ClassLoader->return_class(
+ "use warnings; use strict; package $module;\n"
+ . "use base qw/$method/;\n"
+ . "sub record_class { '$base$model' };\n"
+ . "sub autogenerated { 1 };\n"
+ . "1;" )
+ }
+ else {
+ Jifty->log->debug("Couldn't implement $module using $method");
+ }
+ } elsif ( $module =~ m{^(?:$base)::(Action|Notification)([^\.]+)$} ) {
+ my $method = $plugin . "::" . $1 . $2;
+ if ( Jifty::Util->already_required($method) ) {
+ Jifty->log->debug("Implementing $module using $method");
+ return Jifty::ClassLoader->return_class(
"use warnings; use strict; package $module;\n"
. "use base qw/$method/;\n"
. "sub autogenerated { 1 };\n"
. "1;" )
- if Jifty::Util->already_required($method);
+ }
+ else {
+ Jifty->log->debug("Couldn't implement $module using $method");
+ }
+
}
return undef;
More information about the Jifty-commit
mailing list