But I've noticed that Class::Std doesn't work very well with mod_perl due to the BEGIN{} block it depends on.
Actually it is a CHECK block that is the problem. Because of the way that mod_perl loads code, it does this after the CHECK and INIT phases of the perl compiler have run. This is the code which causes the issue (about line 258 in the lastest version on CPAN):
{
no warnings qw( void );
CHECK { initialize() }
}
Now, I am not sure if this version (0.0.8) works with mod_perl or not, but I did find this code on line 417:
Class::Std::initialize(); # Ensure run-time (and mod_perl) setup is
+done
So it is possible that this version will work with mod_perl, but even if it does, then it should be possible1, to actually just put that same line of code at the very end of a mod_perl startup.pl file, and things should just work.
(1) - I stress should, because I am not TheDamian, and while I have read over the Class::Std code, I do not profess to understand all it's funky corners and details. However, logic and common sense dictate that if the CHECK block is not run, then just running the same code from the CHECK block should just work. But then again, this is TheDamian we are talking about ;)
| [reply] [d/l] [select] |
| [reply] |
| [reply] [d/l] |
I suggest you /msg [id://TheDamian] and ask him, since he's the most likely person to know the answer to your question.
| [reply] |
Class::Std 0.0.8 should now "just work" with mod_perl. From the docs:
"Class::Std::initialize()"
This subroutine sets up all the infrastructure to support your
Class::Std- based class. It is usually called automatically in a
"CHECK" block, or (if the "CHECK" block fails to run -- under
"mod_perl" or "require Class::Std" or "eval "..."") during the
first constructor call made to a Class::Std-based object.
In rare circumstances, you may need to call this subroutine
directly yourself. Specifically, if you set up cumulative,
restricted, private, or automethodical class methods (see below),
and call any of them before you create any objects, then you need
to call "Class::Std::initialize()" first.
So you shouldn't need to call the new subroutine yourself in most cases.
Damian | [reply] [d/l] |