[jifty-devel] RFC: Design change in ClassLoader
jpeacock at rowman.com
Thu Jun 22 15:19:14 EDT 2006
Alex Vandiver wrote:
> Hrm. I'm afraid I don't really understand what you're saying well
> enough to understand the problem -- I don't doubt that there is
> something wrong, but I just don't understand well enough what it is.
> Can you give a more specific example?
Yes, I think so. I created the tutorial application MyWeblog and added
my Login plugin to the etc/config.yml. I added a new class to Jifty
itself called Jifty::Plugin::ClassLoader, which is more or less the same
as the base Jifty::ClassLoader, except that it creates virtual classes
for MyWeblog as wrappers of Jifty::Plugin::Login, instead of Jifty.
This leads to three @INC entries:
1) one for the Jifty::Plugin::Login class itself (to autogenerate e.g.
Action classes for J::P::L::Model::User);
2) one for Jifty::Plugin::ClassLoader, which autocreates wrappers for
MyWeblog using the classes that Jifty::Plugin::Login provides (like
Login, Logout, and Signup);
3) the conventional Jifty::ClassLoader, which autocreates wrappers for
MyWeblog using the Jifty classes.
When Jifty goes to generate classes for MyWeblog::Model::User (which is
inherited from Jifty::Plugin::Login), #2 fires and returns all of the
However, when Jifty does the same thing for MyWeblog::Model::Post (which
is a model class that I created in MyWeblog directly), #2 fires then
returns undef (errors out) trying to provide support for
Jifty::Plugin::Login::Model::Post (which doesn't exist). #3 then fires
and correctly handles all of the classes for MyWeblog::Model::Post out
of Jifty's own classes.
The problem is that once you are inside Jifty::Util->require(), the only
possible results are success or failure (error in the log file), even
though what #2 wants to do is say "never mind me, see if you can resolve
this class in the next @INC entry." By making ClassLoader a plugable
loop, then this isn't an issue. A single array element can fire (match
the $module regex) and then pass to the next by just returning undef.
No errors would be issued, because only a complete failure to match and
succeed from all of the possible hooks would cause require() to fail.
If Jesse has enabled my access to the repository, I'll create a branch
tonight and put up what I have so far. Otherwise, I can generate a diff
so you can see what I have so far.
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Lanham, MD 20706
More information about the jifty-devel