[Jifty-commit] r6221 - in jifty/trunk: lib/Jifty plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace
Jifty commits
jifty-commit at lists.jifty.org
Fri Jan 9 15:45:00 EST 2009
Author: alexmv
Date: Fri Jan 9 15:45:00 2009
New Revision: 6221
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/API.pm
jifty/trunk/lib/Jifty/ClassLoader.pm
jifty/trunk/lib/Jifty/Plugin.pm
jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm
Log:
r40383 at kohr-ah: chmrr | 2009-01-09 15:44:35 -0500
* Plugin actions are automatically mirrored into the application's
namespace by the ClassLoader. Thus, we should _not_ add the
plugin's action classes to the list of user-visible classes, and
instead make the mirrored classes visible via Jifty->api->actions.
Otherwise, applications attempting to lock down available actions
may miss actions provided by plugins -- even if they lock down
Jifty::Plugin::Whatever::Action::Something,
AppName::Action::Something will still quietly exist and be
available to users.
As long as plugins always refer to the application's mirrored
action class -- which they should be doing already for
extensibility -- this change does not affect backwards
compatibility.
Modified: jifty/trunk/lib/Jifty/API.pm
==============================================================================
--- jifty/trunk/lib/Jifty/API.pm (original)
+++ jifty/trunk/lib/Jifty/API.pm Fri Jan 9 15:45:00 2009
@@ -73,7 +73,7 @@
# Setup the basic allow/deny rules
$self->reset;
- # Find all the actions for the API reference (available at _actions)
+ # Find all the actions for the API reference (available at __actions)
Jifty::Module::Pluggable->import(
search_path => [
Jifty->app_class("Action"),
@@ -81,12 +81,32 @@
map {ref($_)."::Action"} Jifty->plugins,
],
except => qr/\.#/,
- sub_name => "_actions",
+ sub_name => "__actions"
);
return ($self);
}
+# Plugin actions under Jifty::Plugin::*::Action are mirrored under
+# AppName::Action by Jifty::ClassLoader; this code makes _actions
+# reflect this mirroring.
+sub _actions {
+ my $self = shift;
+ unless ( $self->{_actions} ) {
+ my @actions = $self->__actions;
+ my %seen;
+ $seen{$_}++ for @actions;
+ for (@actions) {
+ if (/^Jifty::Plugin::(.*)::Action::(.*)$/) {
+ my $classname = Jifty->app_class( Action => $2 );
+ push @actions, $classname unless $seen{$classname};
+ }
+ }
+ $self->{_actions} = \@actions;
+ }
+ return @{ $self->{_actions} };
+}
+
=head2 qualify ACTIONNAME
Returns the fully qualified package name for the given provided
Modified: jifty/trunk/lib/Jifty/ClassLoader.pm
==============================================================================
--- jifty/trunk/lib/Jifty/ClassLoader.pm (original)
+++ jifty/trunk/lib/Jifty/ClassLoader.pm Fri Jan 9 15:45:00 2009
@@ -76,7 +76,7 @@
=item I<Application>::Action::I<Something>
-The class loader will search for a plugin I<Plugin> such that I<Plugin>::Action::I<Something> exists. It will then create an empty class named I<Application>::Action::I<Something> that descends from I<Plugin>::Action::I<Something>.
+The class loader will search for a plugin I<Plugin> such that C<I<Plugin>::Action::I<Something>> exists. It will then create an empty class named I<Application>::Action::I<Something> that descends from I<Plugin>::Action::I<Something>.
This means that a plugin may be written to allow the application to override the default implementation used by the plugin as long as the plugin uses the application version of the class.
@@ -118,7 +118,7 @@
=item I<Application>::Model::I<Something>
-If C<I<Application>::Plugin::I<Plugin>::Model::I<Something>> exists and is a model class, then it creates a subclass of it named C<I<Application>::Model::I<Something>> for the local application.
+If C<I<Plugin>::Model::I<Something>> exists and is a model class, then it creates a subclass of it named C<I<Application>::Model::I<Something>> for the local application.
This allows an application to customize a model provided by a subclass (or choose not to). Plugins should be written to use the application's version.
Modified: jifty/trunk/lib/Jifty/Plugin.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin.pm Fri Jan 9 15:45:00 2009
@@ -103,15 +103,11 @@
=head2 new_request
-Called right before every request. By default, this adds the plugin's
-actions to the list of allowed actions, using L<Jifty::API/allow>.
+Called right before every request. By default, does nothing.
=cut
sub new_request {
- my $self = shift;
- my $class = ref($self) || $self;
- Jifty->api->allow(qr/^\Q$class\E::Action/);
}
sub _calculate_share {
Modified: jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm
==============================================================================
--- jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm (original)
+++ jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace/Dispatcher.pm Fri Jan 9 15:45:00 2009
@@ -11,7 +11,7 @@
on qr'^/__jifty/(edit|create)(_inline|)/(.*?)/(.*)$', run {
my $editor = Jifty->web->new_action(
- class => 'Jifty::Plugin::EditInPlace::Action::FileEditor',
+ class => Jifty->app_class('Action','FileEditor'),
moniker => 'editpage',
arguments => {
source_path => $4,
More information about the Jifty-commit
mailing list