[Catalyst] SOLUTION: Re: Authentication::Store::DBIC works undermyapp_server.pl butnot Apache/mod_perl

Rodney Broom rbroom+catalyst at rbroom.com
Thu Aug 10 19:46:09 CEST 2006


From: "Rodney Broom" <rbroom+catalyst at rbroom.com>

> From: "Christopher H. Laco" <claco at chrislaco.com>
> > ...but doesn't Apache actually load happen twice at
> > startup...once for the config parse, once for the real start?
> > 
> > http://perl.apache.org/docs/1.0/guide/config.html#Apache_Restarts_Twice_On_Start
> 
> 
> Good thinking, but it didn't pan out.

Actually, it did pan out, but I missed it.

In apache conf, global or <VirtualHost>, using:
  PerlModule MyApp

runs twice, just as indicated in the doc. Unfortunatelly, mod_perl appears to be using a require(), since the compile phase runs in MyApp.pm twice and doesn't run import(). I've gotten around this by using a perl block:
  <Perl>
    use lib ...
    use MyApp
  </Perl>

This works just the way you'd expect. The second time MyApp is use'd, the package does not go through the compile phase, and only runs my import(). So, no more 'redifined' messages.


Before I got that part worked out, I found a bug in Catalyst::Utils::ensure_class_loaded(). It wasn't honoring the test to see if the package was already loaded in order to skip loading when not needed, and thereby loaded packages every time. The problem with this (besides loading with require()) is that Module::Pluggable::Object::handle_innerpackages() (called by Module::Pluggable::Object::plugins()) grocks through the symbol table for each package it has found looking for other packages. The packages it finds (on a second compile) include the factory-ized packages under Catalyst::Model::Main. ensure_class_loaded() was trying to load these, but they don't exist on disk, so it failed.


I'll have patches for at least Catalyst/Utils.pm and Catalyst.pm coming soon.


---
Rodney Broom




More information about the Catalyst mailing list