[jifty-devel] Improving our plugin system to make things like
::Login easier
Jesse Vincent
jesse at bestpractical.com
Sun Dec 10 17:01:02 EST 2006
I've been attempting to figure out how to fix the login inheritance
problems that folks have been running into. I think that we've got a
somewhat flawed plugin model. Fundamentally, right now, we're
injecting a set of classes into the current application. For login,
we get this:
Jifty::Plugin::Login::Model::User
Jifty::Plugin::Login::Model::UserCollection
Jifty::Plugin::Login::Action::CreateUser
Jifty::Plugin::Login::Action::SearchUser
Jifty::Plugin::Login::Action::UpdateUser
Jifty::Plugin::Login::Action::DeleteUser
...but your application ends up dealing with MyApp::Model::User,
which you set up as a child class of the login plugin.
Jifty ends up handing the actions for the plugin off to:
Jifty::Plugin::Login::Action::CreateUser
Jifty::Plugin::Login::Action::SearchUser
Jifty::Plugin::Login::Action::UpdateUser
Jifty::Plugin::Login::Action::DeleteUser
As we've already been finding when adding columns to model classes,
this gets really painful when you're not doing exactly what the model
class wants.
An alternate vision is brewing in my head. I'm thinking of doing
something like allowing plugins to manipulate the inheritance tree of
application classes. So you could do something like this:
Create:
Jifty::Plugin::Login::Model::User
Jifty::Plugin::Login::Model::UserCollection
Jifty::Plugin::Login::Action::CreateUser
Jifty::Plugin::Login::Action::SearchUser
Jifty::Plugin::Login::Action::UpdateUser
Jifty::Plugin::Login::Action::DeleteUser
In Jifty::Plugin::Login:
sub init {
my $self = shift;
Jifty::ClassLoader->add_parent_class(
parent => 'Jifty::Plugin::Login::Model::User',
child => $self->application_class . '::Model::User',
after => 'Jifty::Plugin::OpenID::Model::User'
);
#... and so on.
}
Users would work with the standard classes they expect:
MyApp::Model::User
MyApp::Model::UserCollection
MyApp::Action::CreateUser
MyApp::Action::SearchUser
MyApp::Action::UpdateUser
MyApp::Action::DeleteUser
...and plugin authors would have some control over what happens at
require time.
Does this sound like a sane design? I think it would somewhat
simplify our conceptual model and be a lot more flexible. But
thoughts are much appreciated.
-jesse
More information about the jifty-devel
mailing list