Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 17086
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: david [...] bullmedia.com.au
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 0.04001



Subject: DBIx::Class Calls Class::C3 in a Documented Way That Will Not Work
My Class::C3 (version 0.07) says: ## initializers # NOTE: # this will not run under the following # conditions: # - mod_perl # - require Class::C3; # - eval "use Class::C3" # in all those cases, you need to call # the initialize() function manually INIT { initialize() } Now, the Componentized.pm module does: eval "package $target; import Class::C3;" unless exists $table->{$target}; ...Now, whilse the C3 documentation doesn't specify that an "import" will cause it to not run, given that "use" performs and import in a BEGIN (among other things), I think this is why I get: lloy0076@david:~/work/programming/pos$ perl dbix.pl Too late to run INIT block at /usr/local/share/perl/5.8.7/Class/C3.pm line 52. I'm not sure of the solution here. One solution was to comemnt out line 52 of C3.pm (which struck me as silly). The other would be to work out why the call to import is wrapped in an eval in the first place and unwrap it. DSL
Subject: Componentised.pm
package DBIx::Class::Componentised; use Class::C3; sub inject_base { my ($class, $target, @to_inject) = @_; { no strict 'refs'; unshift(@{"${target}::ISA"}, grep { $target ne $_ && !$target->isa($_)} @to_inject); } my $table = { Class::C3::_dump_MRO_table }; eval "package $target; import Class::C3;" unless exists $table->{$target}; Class::C3::reinitialize() if defined $table->{$target}; } sub load_components { my $class = shift; my @comp = map { "DBIx::Class::$_" } grep { $_ !~ /^#/ } @_; $class->_load_components(@comp); } sub load_own_components { my $class = shift; my @comp = map { "${class}::$_" } grep { $_ !~ /^#/ } @_; $class->_load_components(@comp); } sub _load_components { my ($class, @comp) = @_; foreach my $comp (@comp) { eval "use $comp"; die $@ if $@; } $class->inject_base($class => @comp); } 1;
On Mon Jan 16 02:32:10 2006, guest wrote: Show quoted text
> ...Now, whilse the C3 documentation doesn't specify that an "import" > will cause it to not run, given that "use" performs and import in a > BEGIN (among other things), I think this is why I get: > > lloy0076@david:~/work/programming/pos$ perl dbix.pl > Too late to run INIT block at /usr/local/share/perl/5.8.7/Class/C3.pm > line 52.
It is indeed. stevan and I have tried and been unable to find a way to suppress this warning - if you have any suggestions, please post them to the dbic mailing list. Show quoted text
> I'm not sure of the solution here. One solution was to comemnt out line > 52 of C3.pm (which struck me as silly). The other would be to work out > why the call to import is wrapped in an eval in the first place and > unwrap it.
The call to import is a *string* eval because that's the only sane way to set the package for caller(). Plus if the class is late-loaded (which happens for e.g. Catalyst apps) INIT time is already long gone anyway, hence the current approach. Most importantly, however, the current approach *does* work and stevan (the Class::C3 author) has checked it and declared it insane but workable, so I'm marking the ticket rejected :)