Hello all.
I'm currently working on a mod_perl project where I'd like to use Class::Std to simplify and standardise my classes. But I've noticed that Class::Std doesn't work very well with mod_perl due to the BEGIN{} block it depends on. However I read a comment from Damian that he's got a workaround he's going to add to the next version.
Does anyone know what he's planning on doing so that I might be able to do something about it in the mean time?
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 doneSo 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 ;)
I suggest you /msg TheDamian and ask him, since he's the most likely person to know the answer to your question.
Let me suggest you try Object::InsideOut or Class::InsideOut instead of Class::Std. See Slides from NY Inside-Out Talk for reasons why.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
So you shouldn't need to call the new subroutine yourself in most cases."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.
Damian
perlmonks.org content © perlmonks.org and Pic, spiritway, stvn, TheDamian, xdg
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03