Off-list, I'm told my comment > CGI::Application uses Attributes for some things as well, so ... > someone must have [f]igured it out?
is only partially right, as Attributes are only in a C:A:Plugin, http://search.cpan.org/~thilo/CGI-Application-Plugin-AutoRunmode-0.08/Au toRunmode.pm Of course, you'd still want that to work with mod_perl and mod_perl#2 ... However, the "someone must have" comment still applies for Apache::Reload, as the Catalyst folks seem to think it works: ">> One beauty of this scheme is that you could probably work out a way ">> to re-load the rules on the fly, allowing for lightning-quick ">> development and testing. ">> "> "> http://search.cpan.org/~msergeant/Apache-Reload-0.07/Reload.pm "Understood. " [ http://lists.rawmode.org/pipermail/catalyst/2005-June/000496.html ] So, implication is that it works -- the question is how can it work? This prompted me to look up CHECK block or INIT block and mod_perl. Stranger than fiction, the Mod-Perl docs say BEGIN can be reinvoked in mod_perl at sensible times under certain esoteric conditions but neither CHECK or INIT blocks get called, ever. (This seems just wrong, people ought to be encouraged to use CHECK or INIT if that's what they mean. Couldn't they fix this in ModPerl2 ??) Perl only calls these blocks during perl_parse(), which mod_perl calls once at startup time. Therefore CHECK and INIT blocks don't work for the same reason these don't: perl -e 'eval qq(CHECK { print "ok\n" })' perl -e 'eval qq(INIT { print "ok\n" })' Wow. Distressing. And as advertised, the *default* time for an Attribute::Handler to execute is CHECK. But they can be set to INIT time (or BEGIN or END). http://www.perladvent.org/2003/7th/ http://search.cpan.org/~abergman/Attribute-Handlers-0.78/lib/Attribute/H andlers.pm One can imagine a module deciding, while it's loading, to set it's the attribute handlers to be BEGIN blocks if in mod_perl and CHECK blocks if not, and arranging for Reload to trigger the repeating BEGIN block cases, but that's just too weird. So what does it do? Well, let's cheat and look at the code. http://search.cpan.org/src/MRAMBERG/Catalyst-5.33/lib/Catalyst/Base.pm Looks to me like Catalyst is eschewing elegant but problematic Attribute::Handler and going straight down to Perl's native ugly attributes(3pm) http://www.perlpod.com/5.8.4/lib/attributes.html . Since these are built-in, perhaps they're mod_perl friendly and just programmer-hostile? http://search.cpan.org/~mramberg/Catalyst-5.33/lib/Catalyst/Base.pm defines class variables _attr_cache and _action_cache , and subroutines: # note - see attributes(3pm) sub MODIFY_CODE_ATTRIBUTES { my ( $class, $code, @attrs ) = @_; $class->_attr_cache->{$code} = [EMAIL PROTECTED]; push @{ $class->_action_cache }, [ $code, [EMAIL PROTECTED] ]; return (); } sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () } So the answer seems to be: The Catalyst team didn't use the elegant Damian-modules that make the underlying feature much much easier to program but alas don't work under mod_perl since they (ab)use CHECK and INIT blocks to defer work until compilation is done (Class::Delegation has same issue). Having seen what was possible, they just used the same ugly interface that Damian used to get the same effect. Cheers, Bill _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

